Method: ASIR::Environment#config!

Defined in:
lib/asir/environment.rb

#config!(phase, opts = { }) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/asir/environment.rb', line 69

def config! phase, opts = { }
  ((@config ||= { })[phase] ||= [
    begin
      opts[:phase] = phase
      save = { }
      opts.each do | k, v |
        save[k] = send(k)
        send(:"#{k}=", v)
      end
      $stderr.puts "#{self.class} calling #{config_rb} asir.phase=#{phase.inspect} ..." if @verbose >= 1
      value = config_lambda.call(self)
      $stderr.puts "#{self.class} calling #{config_rb} asir.phase=#{phase.inspect} DONE" if @verbose >= 1
      value
    ensure
      save.each do | k , v |
        send(:"#{k}=", v)
      end
    end
    ]).first
end