lib/rollout.rb in rolloutbr-2.0.3br vs lib/rollout.rb in rolloutbr-2.0.4br

- old
+ new

@@ -74,14 +74,19 @@ 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 = {}) @storage = storage @groups = {:all => lambda { |user| true }} @legacy = Legacy.new(@storage) if opts[:migrate] end @@ -152,23 +157,23 @@ @period ||= 60 end def get(feature, force=false) puts "force: #{force}" - puts "!@@cleared: #{!@@cleared}" + puts "!self.class.cleared: #{!self.class.cleared}" puts "Time.now: #{Time.now}" - puts "@@cleared + period: #{@@cleared + period}" - puts "Comp: #{Time.now >= (@@cleared + period)}" - if force || !@@cleared || Time.now >= (@@cleared + period) + puts "self.class.cleared + period: #{self.class.cleared + period}" + puts "Comp: #{Time.now >= (self.class.cleared + period)}" + if force || !self.class.cleared || Time.now >= (self.class.cleared + period) puts "forced" - @@storage_hash = {} - @@cleared = Time.now + self.class.storage_hash = {} + self.class.cleared = Time.now end - if @@storage_hash[feature].nil? + if self.class.storage_hash[feature].nil? puts "nil" - @@storage_hash[feature] = @storage.get(key(feature)) rescue '0||' + self.class.storage_hash[feature] = @storage.get(key(feature)) rescue '0||' end - string = @@storage_hash[feature] + string = self.class.storage_hash[feature] if string || !migrate? Feature.new(feature, string) else info = @legacy.info(feature) f = Feature.new(feature)