class Basquiat::Configuration

Attributes

connection[RW]

@!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
environment[W]

@!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
exchange_name[W]

@!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
logger[W]

@!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
queue_name[W]

@!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
rescue_proc[RW]

@!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

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

adapter_options() click to toggle source

@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
config_file=(path) click to toggle source

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

@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
environment() click to toggle source
# File lib/basquiat/support/configuration.rb, line 54
def environment
  (@environment || ENV['BASQUIAT_ENV'] || 'development').to_sym
end
exchange_name() click to toggle source
# File lib/basquiat/support/configuration.rb, line 46
def exchange_name
  @exchange_name || 'basquiat.exchange'
end
logger() click to toggle source
# File lib/basquiat/support/configuration.rb, line 50
def logger
  @logger || DefaultLogger.new
end
queue_name() click to toggle source
# File lib/basquiat/support/configuration.rb, line 42
def queue_name
  @queue_name || 'basquiat.queue'
end
reload_classes() click to toggle source

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

config() click to toggle source
# File lib/basquiat/support/configuration.rb, line 82
def config
  @yaml.fetch(environment, {})
end
load_yaml(path) click to toggle source
# 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
setup_basic_options() click to toggle source
# 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