Class: Flipflop::Strategies::ActiveRecordStrategy
Instance Attribute Summary
#description, #key, #name, #title
Class Method Summary
collapse
Instance Method Summary
collapse
default_name, #hidden?, #reset!
Constructor Details
Returns a new instance of ActiveRecordStrategy.
10
11
12
13
14
15
16
|
# File 'lib/flipflop/strategies/active_record_strategy.rb', line 10
def initialize(**options)
@class = options.delete(:class) || ::Flipflop::Feature
if !@class.kind_of?(Class)
@class = ActiveSupport::Inflector.constantize(@class.to_s)
end
super(**options)
end
|
Class Method Details
.default_description ⇒ Object
5
6
7
|
# File 'lib/flipflop/strategies/active_record_strategy.rb', line 5
def default_description
"Stores features in database. Applies to all users."
end
|
Instance Method Details
#clear!(feature) ⇒ Object
32
33
34
|
# File 'lib/flipflop/strategies/active_record_strategy.rb', line 32
def clear!(feature)
find(feature).first.try(:destroy)
end
|
#enabled?(feature) ⇒ Boolean
22
23
24
|
# File 'lib/flipflop/strategies/active_record_strategy.rb', line 22
def enabled?(feature)
find(feature).first.try(:enabled?)
end
|
#switch!(feature, enabled) ⇒ Object
26
27
28
29
30
|
# File 'lib/flipflop/strategies/active_record_strategy.rb', line 26
def switch!(feature, enabled)
record = find(feature).first_or_initialize
record.enabled = enabled
record.save!
end
|
#switchable? ⇒ Boolean
18
19
20
|
# File 'lib/flipflop/strategies/active_record_strategy.rb', line 18
def switchable?
true
end
|