34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/msgr/railtie.rb', line 34
def parse_config(cfg)
unless cfg.is_a? Hash
Rails.logger.warn '[Msgr] Could not load rabbitmq config: Config must be a Hash'
return nil
end
unless cfg[Rails.env].is_a?(Hash)
Rails.logger.warn "Could not load rabbitmq config for environment \"#{Rails.env}\": is not a Hash"
return nil
end
cfg = HashWithIndifferentAccess.new cfg[Rails.env]
unless cfg[:uri]
raise ArgumentError, 'Could not load rabbitmq environment config: URI missing.'
end
case cfg[:autostart]
when true, 'true', 'enabled'
cfg[:autostart] = true
when false, 'false', 'disabled', nil
cfg[:autostart] = false
else
raise ArgumentError, "Invalid value for rabbitmq config autostart: \"#{cfg[:autostart]}\""
end
cfg[:routing_file] ||= Rails.root.join('config/msgr.rb').to_s
cfg
end
|