Class: ConfConf::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Configuration

Returns a new instance of Configuration.



26
27
28
29
# File 'lib/conf_conf.rb', line 26

def initialize(&block)
  @parsed_values = {}
  run(block) if block
end

Instance Attribute Details

#parsed_valuesObject (readonly)

Returns the value of attribute parsed_values.



24
25
26
# File 'lib/conf_conf.rb', line 24

def parsed_values
  @parsed_values
end

Instance Method Details

#config(key, options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/conf_conf.rb', line 35

def config(key, options={})
  value = Reference.new(key, options).value

  if block_given?
    value = yield(value)
  end

  @parsed_values[key] = value
end

#run(block) ⇒ Object



31
32
33
# File 'lib/conf_conf.rb', line 31

def run(block)
  instance_eval(&block)
end