Class: BunnyExchanges::Configuration
- Inherits:
-
Object
- Object
- BunnyExchanges::Configuration
- Defined in:
- lib/bunny_exchanges/configuration.rb
Overview
It stores the exchanges configuration.
Constant Summary collapse
- DEFAULT_EXCHANGES_PATH =
"config/exchanges.yml"
- DEFAULT_RABBITMQ_PATH =
"config/rabbitmq.yml"
Instance Attribute Summary collapse
-
#env ⇒ Object
writeonly
Sets the ENV.
-
#exchanges_path ⇒ Object
writeonly
Sets the path of the exchanges configuration file.
-
#rabbitmq_path ⇒ Object
writeonly
Sets the path of the rabbitmq configuration file.
Instance Method Summary collapse
-
#exchanges ⇒ Hash
Loads the configuration YAML file contents.
-
#initialize ⇒ Configuration
constructor
Constructor.
-
#rabbitmq ⇒ Hash
Loads the configuration YAML file contents for the environment if given.
Constructor Details
#initialize ⇒ Configuration
Constructor.
27 28 29 30 |
# File 'lib/bunny_exchanges/configuration.rb', line 27 def initialize @exchanges_path = DEFAULT_EXCHANGES_PATH @rabbitmq_path = DEFAULT_RABBITMQ_PATH end |
Instance Attribute Details
#env=(value) ⇒ Object
Sets the ENV. If it is set, the rabbitmq configuration for that env is taken, otherwise it gets the rabbitmq config file contents directly.
24 25 26 |
# File 'lib/bunny_exchanges/configuration.rb', line 24 def env=(value) @env = value end |
#exchanges_path=(value) ⇒ Object
Sets the path of the exchanges configuration file.
12 13 14 |
# File 'lib/bunny_exchanges/configuration.rb', line 12 def exchanges_path=(value) @exchanges_path = value end |
#rabbitmq_path=(value) ⇒ Object
Sets the path of the rabbitmq configuration file.
17 18 19 |
# File 'lib/bunny_exchanges/configuration.rb', line 17 def rabbitmq_path=(value) @rabbitmq_path = value end |
Instance Method Details
#exchanges ⇒ Hash
Loads the configuration YAML file contents.
35 36 37 |
# File 'lib/bunny_exchanges/configuration.rb', line 35 def exchanges @exchanges ||= YAML.load_file(exchanges_path) end |
#rabbitmq ⇒ Hash
Loads the configuration YAML file contents for the environment if given.
42 43 44 45 46 47 48 |
# File 'lib/bunny_exchanges/configuration.rb', line 42 def rabbitmq @rabbitmq ||= if env rabbitmq_contents.fetch(env) else rabbitmq_contents end end |