Module: Dynamoid::Config

Extended by:
Config, Options
Includes:
ActiveModel::Observing
Included in:
Config
Defined in:
lib/dynamoid/config.rb,
lib/dynamoid/config/options.rb,
lib/dynamoid/config/backoff_strategies/constant_backoff.rb,
lib/dynamoid/config/backoff_strategies/exponential_backoff.rb

Overview

Contains all the basic configuration information required for Dynamoid: both sensible defaults and required fields.

Defined Under Namespace

Modules: BackoffStrategies, Options

Constant Summary collapse

DEFAULT_NAMESPACE =

Since:

  • 3.3.1

if defined?(Rails)
  klass = Rails.application.class
  app_name = Rails::VERSION::MAJOR >= 6 ? klass.module_parent_name : klass.parent_name
  "dynamoid_#{app_name}_#{Rails.env}"
else
  'dynamoid'
end

Instance Method Summary collapse

Methods included from Options

defaults, option, reset, settings

Instance Method Details

#build_backoffObject


89
90
91
92
93
94
95
96
97
98
# File 'lib/dynamoid/config.rb', line 89

def build_backoff
  if backoff.is_a?(Hash)
    name = backoff.keys[0]
    args = backoff.values[0]

    backoff_strategies[name].call(args)
  else
    backoff_strategies[backoff].call
  end
end

#default_loggerObject

The default logger for Dynamoid: either the Rails logger or just stdout.

Since:

  • 0.2.0


66
67
68
# File 'lib/dynamoid/config.rb', line 66

def default_logger
  defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : ::Logger.new($stdout)
end

#loggerObject

Returns the assigned logger instance.

Since:

  • 0.2.0


73
74
75
# File 'lib/dynamoid/config.rb', line 73

def logger
  @logger ||= default_logger
end

#logger=(logger) ⇒ Object

If you want to, set the logger manually to any output you'd like. Or pass false or nil to disable logging entirely.

Since:

  • 0.2.0


80
81
82
83
84
85
86
87
# File 'lib/dynamoid/config.rb', line 80

def logger=(logger)
  case logger
  when false, nil then @logger = ::Logger.new(nil)
  when true then @logger = default_logger
  else
    @logger = logger if logger.respond_to?(:info)
  end
end