Sha256: 18b81d396100c7cb762593f4320595cccbbdf3711ba86d50055f447a097eebdf

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 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: 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
toy-dynamo-0.1.2 lib/toy/dynamo/config.rb
toy-dynamo-0.1.1 lib/toy/dynamo/config.rb