Sha256: 328e392206d7fd9bacebdf78615e70f9f958afb137e8942b148a426690a9e681

Contents?: true

Size: 1.66 KB

Versions: 13

Compression:

Stored size: 1.66 KB

Contents

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

# Shamelessly stolen from Dynamoid
module Toy
  module Dynamo

    # 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
      option :included_models, :default => []
      # 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
      # Use AWS config
      #option :access_key
      #option :secret_key

      # 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
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
toy-dynamo-0.1.0 lib/toy/dynamo/config.rb
toy-dynamo-0.0.15 lib/toy/dynamo/config.rb
toy-dynamo-0.0.14 lib/toy/dynamo/config.rb
toy-dynamo-0.0.13 lib/toy/dynamo/config.rb
toy-dynamo-0.0.12 lib/toy/dynamo/config.rb
toy-dynamo-0.0.11 lib/toy/dynamo/config.rb
toy-dynamo-0.0.10 lib/toy/dynamo/config.rb
toy-dynamo-0.0.9 lib/toy/dynamo/config.rb
toy-dynamo-0.0.8 lib/toy/dynamo/config.rb
toy-dynamo-0.0.7 lib/toy/dynamo/config.rb
toy-dynamo-0.0.6 lib/toy/dynamo/config.rb
toy-dynamo-0.0.5 lib/toy/dynamo/config.rb
toy-dynamo-0.0.4 lib/toy/dynamo/config.rb