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
-
#connections ⇒ Object
writeonly
Sets the hash path of the rabbitmq configuration file.
-
#env ⇒ Object
writeonly
Sets the ENV.
-
#exchanges_path ⇒ Object
writeonly
Sets the path of the exchanges configuration file.
Instance Method Summary collapse
-
#connection_config(connection_name) ⇒ Hash
Loads the configuration YAML file contents for the environment if given.
-
#exchanges ⇒ Hash
Loads the configuration YAML file contents.
-
#initialize ⇒ Configuration
constructor
Constructor.
Constructor Details
#initialize ⇒ Configuration
Constructor.
27 28 29 30 31 |
# File 'lib/bunny_exchanges/configuration.rb', line 27 def initialize @exchanges_path = DEFAULT_EXCHANGES_PATH @connections = {default: DEFAULT_RABBITMQ_PATH} @configs = {} end |
Instance Attribute Details
#connections=(value) ⇒ Object
Sets the hash path of the rabbitmq configuration file.
17 18 19 |
# File 'lib/bunny_exchanges/configuration.rb', line 17 def connections=(value) @connections = value end |
#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 |
Instance Method Details
#connection_config(connection_name) ⇒ Hash
Loads the configuration YAML file contents for the environment if given.
43 44 45 46 47 48 49 |
# File 'lib/bunny_exchanges/configuration.rb', line 43 def connection_config connection_name @configs[connection_name] ||= if env rabbitmq_contents(connection_name).fetch(env) else rabbitmq_contents connection_name end end |
#exchanges ⇒ Hash
Loads the configuration YAML file contents.
36 37 38 |
# File 'lib/bunny_exchanges/configuration.rb', line 36 def exchanges @exchanges ||= YAML.load_file(exchanges_path) end |