Class: ConfConf::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
9
# File 'lib/conf_conf/configuration.rb', line 6

def initialize
  @parsed_values = {}
  @references = {}
end

Instance Attribute Details

#parsed_valuesObject (readonly)

Returns the value of attribute parsed_values.



3
4
5
# File 'lib/conf_conf/configuration.rb', line 3

def parsed_values
  @parsed_values
end

#referencesObject (readonly)

Returns the value of attribute references.



4
5
6
# File 'lib/conf_conf/configuration.rb', line 4

def references
  @references
end

Instance Method Details

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



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/conf_conf/configuration.rb', line 15

def config(key, options={})
  reference = Reference.new(key, options)
  @references[reference.environment_key] = reference

  value = reference.value

  if block_given?
    value = yield(value)
  end

  @parsed_values[key] = value
end

#run(block) ⇒ Object



11
12
13
# File 'lib/conf_conf/configuration.rb', line 11

def run(block)
  instance_eval(&block)
end