From 01c1f977502aaec511eaf530b01f2e70ae9fbc14 Mon Sep 17 00:00:00 2001 From: Stormwind Date: Sat, 25 Apr 2015 15:48:45 +0200 Subject: [PATCH] Drop entries in storage, if more than new length --- lib/rubella/storage.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/rubella/storage.rb b/lib/rubella/storage.rb index 6c79d7f..6aa166b 100644 --- a/lib/rubella/storage.rb +++ b/lib/rubella/storage.rb @@ -22,7 +22,14 @@ module Rubella def length= length @length = length - # TODO drop entries, if more than new length + # Drop entries, if more than new length + if @length.kind_of? Integer + while @data.length > @length + @data.pop + end + end + + @length end # Adds the data from the given storage to the own data and return this as a