Class: Togls::Toggler
- Inherits:
-
Object
- Object
- Togls::Toggler
- Defined in:
- lib/togls/toggler.rb
Instance Method Summary collapse
-
#initialize(toggle_repository, toggle) ⇒ Toggler
constructor
A new instance of Toggler.
- #off ⇒ Object
- #on(rule = nil) ⇒ Object
Constructor Details
#initialize(toggle_repository, toggle) ⇒ Toggler
Returns a new instance of Toggler.
3 4 5 6 |
# File 'lib/togls/toggler.rb', line 3 def initialize(toggle_repository, toggle) @toggle_repository = toggle_repository @toggle = toggle end |
Instance Method Details
#off ⇒ Object
17 18 19 20 21 22 |
# File 'lib/togls/toggler.rb', line 17 def off rule = Togls::Rules::Boolean.new(false) @toggle.rule = rule @toggle_repository.store(@toggle) @toggle end |
#on(rule = nil) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/togls/toggler.rb', line 8 def on(rule = nil) if rule.nil? rule = Togls::Rules::Boolean.new(true) end @toggle.rule = rule @toggle_repository.store(@toggle) @toggle end |