Sha256: 1da70fd37f6298a85c08269cd3fbf7bfedf9a81d7abb575151b02b683f550466

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 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 :logger, :default => defined?(Rails)
    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 :use_ssl, :default => true
    option :port, :default => '443'
    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

    # 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

3 entries across 3 versions & 1 rubygems

Version Path
dynamoid-1.3.2 lib/dynamoid/config.rb
dynamoid-1.3.1 lib/dynamoid/config.rb
dynamoid-1.3.0 lib/dynamoid/config.rb