class FlipFlop::FlipFlop
Attributes
config[R]
Public Instance Methods
configure() { |config| ... }
click to toggle source
Initialize and configure FlipFlop
for use
Example:
>> FlipFlop::get_instance.configure { |config| config[:adapter] = FlipFlop::Adapters::Memory }
Arguments:
configuration block: (block)
# File lib/flip-flop.rb, line 50 def configure @config ||= {} yield @config initialize_adapter end
feature_enabled?(feature_name, actor=nil)
click to toggle source
Check the if a feature should be enabled or not
Example:
>> FlipFlop::get_instance.feature_enabled? :some_feature
Arguments:
feature_name (Symbol)
Returns:
boolean
# File lib/flip-flop.rb, line 67 def feature_enabled?(feature_name, actor=nil) public_send feature_type(feature_name), feature_value(feature_name), actor rescue false end
Private Instance Methods
initialize_adapter()
click to toggle source
If no adapter has been configured, use memory, then run the `after_initialize` method defined in the adapter if it's there
# File lib/flip-flop.rb, line 77 def initialize_adapter # if no adapter has been initialized, use memory adapter config[:adapter] ||= Adapters::Memory extend config[:adapter] after_initialize if respond_to? :after_initialize end