Class: Proc

Inherits:
Object show all
Defined in:
lib/fqdn_facts/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#call_with_vars(vars, *args) ⇒ Object



89
90
91
92
93
94
95
96
97
98
# File 'lib/fqdn_facts/core_ext.rb', line 89

def call_with_vars(vars, *args)
  begin
    Struct.new(*vars.keys).new(*vars.values).instance_exec(*args, &self)
  rescue NameError => e
    # don't error out - just warn
    file, line = e.backtrace.first.split(':')
    name = e.message.split(/[`']/)[1]
    warn "Couldn't find value for key '#{name}' at #{file}:#{line}"
  end
end