Sha256: dfb93e570ec7a00a715c7e5163e6b895bc384416fc8180df273f4238355c8e28

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

# encoding: utf-8
require 'uri'
require 'dynamoid/config/options'

module Dynamoid

  # Contains all the basic configuration information required for Dynamoid: both sensible defaults and required fields.
  module Config
    extend self
    extend Options
    include ActiveModel::Observing if defined?(ActiveModel::Observing)

    # All the default options.
    option :adapter, default: 'aws_sdk_v2'
    option :namespace, default: defined?(Rails) ? "dynamoid_#{Rails.application.class.parent_name}_#{Rails.env}" : 'dynamoid'
    option :access_key, default: nil
    option :secret_key, default: nil
    option :region, default: nil
    option :batch_size, default: 100
    option :read_capacity, default: 100
    option :write_capacity, default: 20
    option :warn_on_scan, default: true
    option :endpoint, default: nil
    option :identity_map, default: false
    option :timestamps, default: true
    option :sync_retry_max_times, default: 60 # a bit over 2 minutes
    option :sync_retry_wait_seconds, default: 2
    option :convert_big_decimal, default: false
    option :models_dir, default: 'app/models' # perhaps you keep your dynamoid models in a different directory?
    option :application_timezone, default: :local # available values - :utc, :local, time zone names

    # The default logger for Dynamoid: either the Rails logger or just stdout.
    #
    # @since 0.2.0
    def default_logger
      defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : ::Logger.new($stdout)
    end

    # Returns the assigned logger instance.
    #
    # @since 0.2.0
    def logger
      @logger ||= default_logger
    end

    # 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
    def logger=(logger)
      case logger
      when false, nil then @logger = nil
      when true then @logger = default_logger
      else
        @logger = logger if logger.respond_to?(:info)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dynamoid-2.0.0 lib/dynamoid/config.rb