Class: Feature::Config
- Inherits:
-
Object
- Object
- Feature::Config
- Defined in:
- lib/feature/config.rb
Instance Attribute Summary collapse
-
#backend_obj ⇒ Object
readonly
Returns the value of attribute backend_obj.
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
Instance Method Summary collapse
- #backend(backend) ⇒ Object
-
#feature(name, opts = {}) ⇒ Object
Config DSL method for defining a new feature.
-
#initialize(block = nil) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(block = nil) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 |
# File 'lib/feature/config.rb', line 11 def initialize(block = nil) @features = {} @groups = Set.new instance_eval &block unless block.nil? end |
Instance Attribute Details
#backend_obj ⇒ Object (readonly)
Returns the value of attribute backend_obj.
9 10 11 |
# File 'lib/feature/config.rb', line 9 def backend_obj @backend_obj end |
#features ⇒ Object (readonly)
Returns the value of attribute features.
7 8 9 |
# File 'lib/feature/config.rb', line 7 def features @features end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
8 9 10 |
# File 'lib/feature/config.rb', line 8 def groups @groups end |
Instance Method Details
#backend(backend) ⇒ Object
24 25 26 |
# File 'lib/feature/config.rb', line 24 def backend(backend) @backend_obj = backend end |
#feature(name, opts = {}) ⇒ Object
Config DSL method for defining a new feature
18 19 20 21 22 |
# File 'lib/feature/config.rb', line 18 def feature(name, opts = {}) raise "Feature '#{name}' already exists" if @features.include?(name) opts[:default] = true unless opts.include?(:default) @features[name] = opts end |