Class: Arkency::FeatureToggle
- Inherits:
-
Object
- Object
- Arkency::FeatureToggle
- Defined in:
- lib/arkency/feature_toggle.rb,
lib/arkency/feature_toggle/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #for(name, &block) ⇒ Object
-
#initialize ⇒ FeatureToggle
constructor
A new instance of FeatureToggle.
- #on?(name, *args) ⇒ Boolean
- #with(name, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ FeatureToggle
Returns a new instance of FeatureToggle.
5 6 7 |
# File 'lib/arkency/feature_toggle.rb', line 5 def initialize @flags = Hash.new end |
Instance Method Details
#for(name, &block) ⇒ Object
17 18 19 |
# File 'lib/arkency/feature_toggle.rb', line 17 def for(name, &block) @flags[name] = block end |
#on?(name, *args) ⇒ Boolean
13 14 15 |
# File 'lib/arkency/feature_toggle.rb', line 13 def on?(name, *args) @flags.fetch(name, proc{|*_args| false }).call(*args) end |
#with(name, *args, &block) ⇒ Object
9 10 11 |
# File 'lib/arkency/feature_toggle.rb', line 9 def with(name, *args, &block) block.call if on?(name, *args) end |