module FlipFlop::Adapters::ActiveRecord
Public Instance Methods
disable_feature(name)
click to toggle source
Diable the feature by deleting the record from the DB
# File lib/flip-flop/adapters/active_record.rb, line 30 def disable_feature(name) get_feature(name).delete end
feature_enabled?(feature_name, actor=nil)
click to toggle source
override this method to prevent the feature being loaded from the database twice.
# File lib/flip-flop/adapters/active_record.rb, line 9 def feature_enabled?(feature_name, actor=nil) f = get_feature(feature_name) public_send f.gate_type, f.value, actor rescue false end
feature_type(name)
click to toggle source
here for compatability, should not really be used
# File lib/flip-flop/adapters/active_record.rb, line 35 def feature_type(name) get_feature(name).gate_type.to_sym end
feature_value(name)
click to toggle source
here for compatabilty, should not really be used
# File lib/flip-flop/adapters/active_record.rb, line 40 def feature_value(name) get_feature(name).value end
get_feature(name)
click to toggle source
# File lib/flip-flop/adapters/active_record.rb, line 16 def get_feature(name) Feature::find_by_name(name) end
set_feature(name, gate_type, value)
click to toggle source
Load the record from the DB if it's already there, and store the gate type and value
# File lib/flip-flop/adapters/active_record.rb, line 22 def set_feature(name, gate_type, value) f = Feature::find_or_initialize_by(name: name) f.gate_type = gate_type f.value = value f.save end