Class: Flipper::Feature
- Inherits:
-
Object
- Object
- Flipper::Feature
- Defined in:
- lib/flipper/feature.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #disable(thing = Types::Boolean.new) ⇒ Object
- #disabled?(actor = nil) ⇒ Boolean
- #enable(thing = Types::Boolean.new) ⇒ Object
- #enabled?(actor = nil) ⇒ Boolean
-
#initialize(name, adapter) ⇒ Feature
constructor
A new instance of Feature.
Constructor Details
#initialize(name, adapter) ⇒ Feature
Returns a new instance of Feature.
11 12 13 14 |
# File 'lib/flipper/feature.rb', line 11 def initialize(name, adapter) @name = name @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/flipper/feature.rb', line 9 def adapter @adapter end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/flipper/feature.rb', line 8 def name @name end |
Instance Method Details
#disable(thing = Types::Boolean.new) ⇒ Object
20 21 22 |
# File 'lib/flipper/feature.rb', line 20 def disable(thing = Types::Boolean.new) gate_for(thing).disable(thing) end |
#disabled?(actor = nil) ⇒ Boolean
28 29 30 |
# File 'lib/flipper/feature.rb', line 28 def disabled?(actor = nil) !enabled?(actor) end |
#enable(thing = Types::Boolean.new) ⇒ Object
16 17 18 |
# File 'lib/flipper/feature.rb', line 16 def enable(thing = Types::Boolean.new) gate_for(thing).enable(thing) end |
#enabled?(actor = nil) ⇒ Boolean
24 25 26 |
# File 'lib/flipper/feature.rb', line 24 def enabled?(actor = nil) !! catch(:short_circuit) { gates.detect { |gate| gate.open?(actor) } } end |