Class: YamlConfiguration::PlaceholdersPreprocessor

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ PlaceholdersPreprocessor

Returns a new instance of PlaceholdersPreprocessor.



3
4
5
# File 'lib/yaml_configuration/placeholders_preprocessor.rb', line 3

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#parse(value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/yaml_configuration/placeholders_preprocessor.rb', line 7

def parse(value)
  if value.respond_to?(:each)
    value.map {|v| self.parse(v)}
  else
    begin
      value.to_s.gsub(/\${([^}]*)}/) { @configuration.instance_eval($1) } 
    rescue Exception => ex
      puts @configuration.inspect
      raise ex
    end
  end
end