Module: Toggleable::Base::ClassMethods
- Defined in:
- lib/toggleable/base.rb
Overview
it will generate these methods into included class.
Instance Method Summary collapse
- #activate!(actor: nil) ⇒ Object
- #active? ⇒ Boolean
- #deactivate!(actor: nil) ⇒ Object
- #description ⇒ Object
- #key ⇒ Object
-
#process ⇒ Object
should we encourage proxy classes.
Instance Method Details
#activate!(actor: nil) ⇒ Object
28 29 30 |
# File 'lib/toggleable/base.rb', line 28 def activate!(actor: nil) toggle_key(true, actor) end |
#active? ⇒ Boolean
20 21 22 23 24 25 26 |
# File 'lib/toggleable/base.rb', line 20 def active? return to_bool(toggle_active.to_s) unless toggle_active.nil? # Lazily register the key Toggleable.configuration.storage.set_if_not_exist(key, DEFAULT_VALUE, namespace: Toggleable.configuration.namespace) DEFAULT_VALUE end |
#deactivate!(actor: nil) ⇒ Object
32 33 34 |
# File 'lib/toggleable/base.rb', line 32 def deactivate!(actor: nil) toggle_key(false, actor) end |
#description ⇒ Object
40 41 42 |
# File 'lib/toggleable/base.rb', line 40 def description name end |
#key ⇒ Object
36 37 38 |
# File 'lib/toggleable/base.rb', line 36 def key @key ||= name.underscore end |
#process ⇒ Object
should we encourage proxy classes
45 46 47 |
# File 'lib/toggleable/base.rb', line 45 def process yield if active? end |