class Togls::Toggler

Toggle Toggler

The Toggle Toggler provides the convenience interface of being able to toggle a feature on/off via the `on` or `off` methods respectively.

Public Class Methods

new(toggle_repository, toggle) click to toggle source
# File lib/togls/toggler.rb, line 11
def initialize(toggle_repository, toggle)
  @toggle_repository = toggle_repository
  @toggle = toggle
end

Public Instance Methods

off() click to toggle source
# File lib/togls/toggler.rb, line 23
def off
  rule = Togls::Rules::Boolean.new(:off, :boolean, false)
  @toggle.rule = rule
  @toggle_repository.store(@toggle)
  @toggle
end
on(rule = nil) click to toggle source
# File lib/togls/toggler.rb, line 16
def on(rule = nil)
  rule = Togls::Rules::Boolean.new(:on, :boolean, true) if rule.nil?
  @toggle.rule = rule
  @toggle_repository.store(@toggle)
  @toggle
end