Class: Flagship::Dsl
- Inherits:
-
Object
- Object
- Flagship::Dsl
- Defined in:
- lib/flagship/dsl.rb
Defined Under Namespace
Classes: InvalidOptionError
Instance Method Summary collapse
- #disable(key, opts = {}) ⇒ Object
- #enable(key, opts = {}) ⇒ Object
- #flagset ⇒ Object
-
#initialize(key, context, base = nil, &block) ⇒ Dsl
constructor
A new instance of Dsl.
Constructor Details
#initialize(key, context, base = nil, &block) ⇒ Dsl
Returns a new instance of Dsl.
4 5 6 7 8 9 10 |
# File 'lib/flagship/dsl.rb', line 4 def initialize(key, context, base = nil, &block) @key = key @context = context @base = base @flags = {} @definition = block end |
Instance Method Details
#disable(key, opts = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/flagship/dsl.rb', line 20 def disable(key, opts = {}) raise InvalidOptionError.new("Option :if is not available for #disable") if opts[:if] @flags[key] = false end |
#enable(key, opts = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/flagship/dsl.rb', line 12 def enable(key, opts = {}) if opts[:if] @flags[key] = opts[:if] else @flags[key] = true end end |