Class: Togls::Feature
- Inherits:
-
Object
- Object
- Togls::Feature
- Defined in:
- lib/togls/feature.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key) ⇒ Feature
constructor
A new instance of Feature.
- #off ⇒ Object
- #on(rule = nil) ⇒ Object
- #on?(target = nil) ⇒ Boolean
Constructor Details
#initialize(key) ⇒ Feature
Returns a new instance of Feature.
5 6 7 8 |
# File 'lib/togls/feature.rb', line 5 def initialize(key) @key = key off end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/togls/feature.rb', line 3 def key @key end |
Instance Method Details
#off ⇒ Object
17 18 19 |
# File 'lib/togls/feature.rb', line 17 def off @rule = Rule.new { false } end |
#on(rule = nil) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/togls/feature.rb', line 10 def on(rule = nil) if rule.nil? rule = Rule.new { true } end @rule = rule end |
#on?(target = nil) ⇒ Boolean
21 22 23 |
# File 'lib/togls/feature.rb', line 21 def on?(target = nil) @rule.run(target) end |