Module: Circuitry::Config::FileLoader

Defined in:
lib/circuitry/config/file_loader.rb

Class Method Summary collapse

Class Method Details

.load(cfile, environment = 'development') ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/circuitry/config/file_loader.rb', line 8

def self.load(cfile, environment = 'development')
  return nil unless File.exist?(cfile)

  opts = {}
  opts = YAML.load(ERB.new(IO.read(cfile)).result) || opts
  opts = opts.merge(opts.delete(environment) || {})

  publisher_opts = opts.merge(opts.delete('publisher') || {})
  subscriber_opts = opts.merge(opts.delete('subscriber') || {})

  Circuitry.subscriber_config = subscriber_opts
  Circuitry.publisher_config = publisher_opts
  true
end