Sha256: b6d9941a3cccebce92ce0e54bac125c252c35164ec4863495926a890f8f7e698

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

# encoding: utf-8
require "uri"
require "dyna_model/config/options"

# Shamelessly stolen from Dynamoid
module DynaModel

  # Contains all the basic configuration information required for Dynamoid: both sensible defaults and required fields.
  module Config
    extend self
    extend Options

    # All the default options.
    option :logger, default: defined?(Rails)
    option :read_provision, default: 50
    option :write_provision, default: 10
    # TODO - default adapter client based on config
    #option :namespace, :default => defined?(Rails) ? "#{Rails.application.class.parent_name}_#{Rails.env}" : ""
    option :endpoint, default: 'dynamodb.us-west-2.amazonaws.com'
    option :port, default: 443
    option :use_ssl, default: true
    option :default_guid_delimiter, default: ":"
    option :namespace, default: ""

    option :lock_extension_read_provision, default: 10
    option :lock_extension_write_provision, default: 4
    option :lock_extension_shard_name, default: "lock"

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

    # Returns the assigned logger instance.
    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.
    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

4 entries across 4 versions & 1 rubygems

Version Path
dyna_model-0.0.12 lib/dyna_model/config.rb
dyna_model-0.0.11 lib/dyna_model/config.rb
dyna_model-0.0.10 lib/dyna_model/config.rb
dyna_model-0.0.9 lib/dyna_model/config.rb