Class: Feature::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/feature/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_objObject (readonly)

Returns the value of attribute backend_obj.



9
10
11
# File 'lib/feature/config.rb', line 9

def backend_obj
  @backend_obj
end

#featuresObject (readonly)

Returns the value of attribute features.



7
8
9
# File 'lib/feature/config.rb', line 7

def features
  @features
end

#groupsObject (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