lib/flipper.rb in flipper-0.11.0 vs lib/flipper.rb in flipper-0.12.0

- old
+ new

@@ -30,11 +30,11 @@ end # Public: Sets Flipper::Configuration instance. def configuration=(configuration) # need to reset flipper instance if configuration changes - Thread.current[:flipper_instance] = nil + self.instance = nil @configuration = configuration end # Public: Default per thread flipper instance if configured. You should not # need to use this directly as most of the Flipper::DSL methods are delegated @@ -44,10 +44,17 @@ # Returns Flipper::DSL instance. def instance Thread.current[:flipper_instance] ||= configuration.default end + # Public: Set the flipper instance. It is most common to use the + # Configuration#default to set this instance, but for things like the test + # environment, this writer is actually useful. + def instance=(flipper) + Thread.current[:flipper_instance] = flipper + end + # Public: All the methods delegated to instance. These should match the # interface of Flipper::DSL. def_delegators :instance, :enabled?, :enable, :disable, :bool, :boolean, :enable_actor, :disable_actor, :actor, @@ -55,10 +62,11 @@ :enable_percentage_of_actors, :disable_percentage_of_actors, :actors, :percentage_of_actors, :enable_percentage_of_time, :disable_percentage_of_time, :time, :percentage_of_time, :features, :feature, :[], :preload, :preload_all, - :adapter, :add, :remove, :import + :adapter, :add, :remove, :import, + :memoize=, :memoizing? # Public: Use this to register a group by name. # # name - The Symbol name of the group. # block - The block that should be used to determine if the group matches a