Class: Basquiat::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/basquiat/support/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



14
15
16
17
18
19
20
21
22
# 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

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



40
41
42
# File 'lib/basquiat/support/configuration.rb', line 40

def connection
  @connection
end

#connection - Makes Basquiat to use a provided connection(-MakesBasquiattouseaprovidedconnection) ⇒ Object

Returns the provided connection.

Returns:

  • (Object)

    the provided connection



40
# File 'lib/basquiat/support/configuration.rb', line 40

attr_accessor :connection, :rescue_proc

#environmentSymbol

Return the set environment or the value of the ‘BASQUIAT_ENV’ environment variable or :development

Returns:

  • (Symbol)

    return the set environment or the value of the ‘BASQUIAT_ENV’ environment variable or :development



33
# File 'lib/basquiat/support/configuration.rb', line 33

attr_writer :queue_name, :exchange_name, :logger, :environment

#exchange_nameString

Returns the exchange name. Defaults to ‘basquiat.exchange’.

Returns:

  • (String)

    the exchange name. Defaults to ‘basquiat.exchange’



33
# File 'lib/basquiat/support/configuration.rb', line 33

attr_writer :queue_name, :exchange_name, :logger, :environment

#loggerLogger

Return the application logger. Defaults to DefaultLogger.

Returns:

  • (Logger)

    return the application logger. Defaults to DefaultLogger.



33
# File 'lib/basquiat/support/configuration.rb', line 33

attr_writer :queue_name, :exchange_name, :logger, :environment

#queue_nameString

Returns the queue name. Defaults to ‘basquiat.queue’.

Returns:

  • (String)

    the queue name. Defaults to ‘basquiat.queue’



33
# File 'lib/basquiat/support/configuration.rb', line 33

attr_writer :queue_name, :exchange_name, :logger, :environment

#rescue_proc#call

Return the callable to be executed when some exception is thrown. The callable receives the exception and message

Returns:

  • (#call)

    return the callable to be executed when some exception is thrown. The callable receives the exception and message



40
# File 'lib/basquiat/support/configuration.rb', line 40

attr_accessor :connection, :rescue_proc

Instance Method Details

#adapter_optionsHash

Return the configured adapter options. Defaults to an empty Hash

Returns:

  • (Hash)

    return the configured adapter options. Defaults to an empty Hash



66
67
68
# File 'lib/basquiat/support/configuration.rb', line 66

def adapter_options
  config.fetch(:adapter_options) { {} }
end

#config_file=(path) ⇒ Object

Loads a YAML file with the configuration options

Parameters:

  • path (String)

    the path of the configuration file



60
61
62
63
# File 'lib/basquiat/support/configuration.rb', line 60

def config_file=(path)
  load_yaml(path)
  setup_basic_options
end

#default_adapterString

Return the configured default adapter. Defaults to Adapters::Test

Returns:

  • (String)

    return the configured default adapter. Defaults to Adapters::Test



71
72
73
# File 'lib/basquiat/support/configuration.rb', line 71

def default_adapter
  config.fetch(:default_adapter) { 'Basquiat::Adapters::Test' }
end

#reload_classesObject

Used by the railtie. Forces the reconfiguration of all extended classes



76
77
78
# File 'lib/basquiat/support/configuration.rb', line 76

def reload_classes
  Basquiat::Base.reconfigure_children
end