diff options
| author | mo khan <mo@mokhan.ca> | 2015-11-07 15:14:40 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-11-07 15:14:40 -0700 |
| commit | 7a73f5aec92f7390669f9836492fe9700e7421cb (patch) | |
| tree | a6c78f2889dc47e5fe41645d167a2224558f27b8 /lib/killjoy/amqp_configuration.rb | |
| parent | c6b1442c77238391a68d70b8478835441f8bb304 (diff) | |
move RMQ configuration to a yaml file.
Diffstat (limited to 'lib/killjoy/amqp_configuration.rb')
| -rw-r--r-- | lib/killjoy/amqp_configuration.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/killjoy/amqp_configuration.rb b/lib/killjoy/amqp_configuration.rb new file mode 100644 index 0000000..87bfab3 --- /dev/null +++ b/lib/killjoy/amqp_configuration.rb @@ -0,0 +1,39 @@ +module Killjoy + class AMQPConfiguration + attr_reader :environment + + def initialize(environment: ENV.fetch("ENV", "development")) + @environment = environment + end + + def amqp_uri + configuration['amqp_uri'] + end + + def exchange + configuration['exchange'] + end + + def exchange_type + configuration['exchange_type'] + end + + def shards + configuration['shards'].to_i + end + + def to_hash + configuration + end + + private + + def configuration(file = "config/amqp.yml") + @configuration ||= YAML.load(expand_template(file))[environment] + end + + def expand_template(file) + ERB.new(File.read(file)).result(binding) + end + end +end |
