Class: Flop::Feature
- Inherits:
-
Object
- Object
- Flop::Feature
- Defined in:
- lib/flop/feature.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
- #activate ⇒ Object
- #active? ⇒ Boolean
- #deactivate ⇒ Object
- #inactive? ⇒ Boolean
-
#initialize(name, repo = Flop.repo) ⇒ Feature
constructor
A new instance of Feature.
- #set(value) ⇒ Object
- #toggle ⇒ Object
- #with {|block| ... } ⇒ Object
- #without {|block| ... } ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/flop/feature.rb', line 3 def name @name end |
#repo ⇒ Object
Returns the value of attribute repo.
3 4 5 |
# File 'lib/flop/feature.rb', line 3 def repo @repo end |
Instance Method Details
#activate ⇒ Object
23 24 25 |
# File 'lib/flop/feature.rb', line 23 def activate set true end |
#active? ⇒ Boolean
10 11 12 |
# File 'lib/flop/feature.rb', line 10 def active? repo.get(name) end |
#deactivate ⇒ Object
27 28 29 |
# File 'lib/flop/feature.rb', line 27 def deactivate set false end |
#inactive? ⇒ Boolean
14 15 16 |
# File 'lib/flop/feature.rb', line 14 def inactive? !active? end |
#set(value) ⇒ Object
18 19 20 21 |
# File 'lib/flop/feature.rb', line 18 def set(value) repo.set(name, value) value end |
#toggle ⇒ Object
31 32 33 |
# File 'lib/flop/feature.rb', line 31 def toggle set !active? end |
#with {|block| ... } ⇒ Object
35 36 37 |
# File 'lib/flop/feature.rb', line 35 def with(&block) yield block if active? end |
#without {|block| ... } ⇒ Object
39 40 41 |
# File 'lib/flop/feature.rb', line 39 def without(&block) yield block if inactive? end |