class BunnyExchanges::Configuration

It stores the exchanges configuration.

Constants

DEFAULT_EXCHANGES_PATH
DEFAULT_RABBITMQ_PATH

Attributes

connections[RW]

Sets the hash path of the rabbitmq configuration file.

@param [Hash] {:connection_name => “path_to_config.yml”}.

env[RW]

Sets the ENV. If it is set, the rabbitmq configuration for that env is taken, otherwise it gets the rabbitmq config file contents directly.

@param [String] the env.

exchanges_path[RW]

Sets the path of the exchanges configuration file.

@param [String] a path.

Public Class Methods

new() click to toggle source

Constructor.

# File lib/bunny_exchanges/configuration.rb, line 27
def initialize
  @exchanges_path = DEFAULT_EXCHANGES_PATH
  @connections    = {default: DEFAULT_RABBITMQ_PATH}
  @configs = {}
end

Public Instance Methods

connection_config(connection_name) click to toggle source

Loads the configuration YAML file contents for the environment if given.

@return [Hash] the rabbitmq configuration.

# 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() click to toggle source

Loads the configuration YAML file contents.

@return [Hash] the exchanges configuration.

# File lib/bunny_exchanges/configuration.rb, line 36
def exchanges
  @exchanges ||= YAML.load_file(exchanges_path)
end

Private Instance Methods

rabbitmq_contents(connection_name) click to toggle source
# File lib/bunny_exchanges/configuration.rb, line 53
def rabbitmq_contents connection_name
  YAML.load_file(connections[connection_name])
end