Class: BlendedConfig::OptionGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/blended_config/option_group.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, &options) ⇒ OptionGroup

Returns a new instance of OptionGroup.



5
6
7
8
9
10
# File 'lib/blended_config/option_group.rb', line 5

def initialize(name, &options)
  @name      = name
  @resolvers = []

  instance_exec(&options)
end

Instance Method Details

#bind_source(key, source) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/blended_config/option_group.rb', line 22

def bind_source(key, source)
  source.prefix_with(@name)

  @resolvers.each do |resolver|
    resolver.bind_source(key, source)
  end
end

#option(option_name, &resolution) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/blended_config/option_group.rb', line 12

def option(option_name, &resolution)
  resolver = OptionResolver.new(option_name, &resolution)

  @resolvers << resolver

  self.class.class_exec do
    define_method(option_name) { resolver.value }
  end
end