lib/rollout.rb in rolloutbr-2.0.8br vs lib/rollout.rb in rolloutbr-2.1br

- old
+ new

@@ -74,20 +74,15 @@ rollout.active_in_group?(g, user) end end end + @@storage_hash = {} + @@cleared = Time.now + puts @@cleared - @storage_hash = {} - @cleared = Time.now - - class << self - attr_accessor :storage_hash, :cleared - end - def initialize(storage, opts = {}) - self.class.storage_hash = {} @storage = storage @groups = {:all => lambda { |user| true }} @legacy = Legacy.new(@storage) if opts[:migrate] end @@ -156,18 +151,20 @@ def period @period ||= 60 end def get(feature, force=false) - if force || !self.class.cleared || Time.now >= (self.class.cleared + period) - self.class.storage_hash = {} - self.class.cleared = Time.now + if force || !@@cleared || Time.now >= (@@cleared + period) + puts "forced" + @@storage_hash = {} + @@cleared = Time.now end - if self.class.storage_hash[feature].nil? - self.class.storage_hash[feature] = @storage.get(key(feature)) rescue '0||' + if @@storage_hash[feature].nil? + puts "nil" + @@storage_hash[feature] = @storage.get(key(feature)) || '0||' end - string = self.class.storage_hash[feature] + string = @@storage_hash[feature] if string || !migrate? Feature.new(feature, string) else info = @legacy.info(feature) f = Feature.new(feature) @@ -191,16 +188,15 @@ def features_key "feature:__features__" end def with_feature(feature) - f = get(feature, true) + f = get(feature) yield(f) save(f) end def save(feature) - self.class.storage_hash = {} @storage.set(key(feature.name), feature.serialize) @storage.set(features_key, (features | [feature.name]).join(",")) end def migrate?