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



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

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



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

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



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

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



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

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