class Basquiat::Configuration
Attributes
@!attribute connection - Makes Basquiat
to use a provided connection
@return [Object] the provided connection
@!attribute rescue_proc
@return [#call] return the callable to be executed when some exception is thrown. The callable receives the exception and message
@!attribute queue_name
@return [String] the queue name. Defaults to 'basquiat.queue'
@!attribute exchange_name
@return [String] the exchange name. Defaults to 'basquiat.exchange'
@!attribute logger
@return [Logger] return the application logger. Defaults to {DefaultLogger}.
@!attribute environment
@return [Symbol] return the set environment or the value of the 'BASQUIAT_ENV' environment variable or :development
@!attribute queue_name
@return [String] the queue name. Defaults to 'basquiat.queue'
@!attribute exchange_name
@return [String] the exchange name. Defaults to 'basquiat.exchange'
@!attribute logger
@return [Logger] return the application logger. Defaults to {DefaultLogger}.
@!attribute environment
@return [Symbol] return the set environment or the value of the 'BASQUIAT_ENV' environment variable or :development
@!attribute queue_name
@return [String] the queue name. Defaults to 'basquiat.queue'
@!attribute exchange_name
@return [String] the exchange name. Defaults to 'basquiat.exchange'
@!attribute logger
@return [Logger] return the application logger. Defaults to {DefaultLogger}.
@!attribute environment
@return [Symbol] return the set environment or the value of the 'BASQUIAT_ENV' environment variable or :development
@!attribute queue_name
@return [String] the queue name. Defaults to 'basquiat.queue'
@!attribute exchange_name
@return [String] the exchange name. Defaults to 'basquiat.exchange'
@!attribute logger
@return [Logger] return the application logger. Defaults to {DefaultLogger}.
@!attribute environment
@return [Symbol] return the set environment or the value of the 'BASQUIAT_ENV' environment variable or :development
@!attribute connection - Makes Basquiat
to use a provided connection
@return [Object] the provided connection
@!attribute rescue_proc
@return [#call] return the callable to be executed when some exception is thrown. The callable receives the exception and message
Public Class Methods
# File lib/basquiat/support/configuration.rb, line 14 def initialize @yaml = {} @rescue_proc = lambda do |exception, message| logger.error do { exception: exception, backtrace: exception.backtrace, message: message }.to_json end raise exception end end
Public Instance Methods
@return [Hash] return the configured adapter options. Defaults to an empty {::Hash}
# File lib/basquiat/support/configuration.rb, line 66 def adapter_options config.fetch(:adapter_options) { {} } end
Loads a YAML file with the configuration options @param path [String] the path of the configuration file
# File lib/basquiat/support/configuration.rb, line 60 def config_file=(path) load_yaml(path) setup_basic_options end
@return [String] return the configured default adapter. Defaults to {Adapters::Test}
# File lib/basquiat/support/configuration.rb, line 71 def default_adapter config.fetch(:default_adapter) { 'Basquiat::Adapters::Test' } end
# File lib/basquiat/support/configuration.rb, line 54 def environment (@environment || ENV['BASQUIAT_ENV'] || 'development').to_sym end
# File lib/basquiat/support/configuration.rb, line 46 def exchange_name @exchange_name || 'basquiat.exchange' end
# File lib/basquiat/support/configuration.rb, line 50 def logger @logger || DefaultLogger.new end
# File lib/basquiat/support/configuration.rb, line 42 def queue_name @queue_name || 'basquiat.queue' end
Used by the railtie. Forces the reconfiguration of all extended classes
# File lib/basquiat/support/configuration.rb, line 76 def reload_classes Basquiat::Base.reconfigure_children end
Private Instance Methods
# File lib/basquiat/support/configuration.rb, line 82 def config @yaml.fetch(environment, {}) end
# File lib/basquiat/support/configuration.rb, line 86 def load_yaml(path) @yaml = YAML.safe_load(ERB.new(IO.readlines(path).join).result, [Symbol], [], true).symbolize_keys end
# File lib/basquiat/support/configuration.rb, line 90 def setup_basic_options @queue_name ||= config.fetch(:queue_name) { 'basquiat.exchange' } @exchange_name ||= config.fetch(:exchange_name) { 'basquiat.queue' } end