Sha256: a15ccd9ac35811ea3b88ddebe783c16984b43e1eb6b2c1bbb7b200d6423f0c18

Contents?: true

Size: 857 Bytes

Versions: 5

Compression:

Stored size: 857 Bytes

Contents

# encoding: utf-8
module Dynamoid #:nodoc:

  module Adapter
    extend self
    
    def adapter
      reconnect! unless @adapter
      @adapter
    end
    
    def reconnect!
      require "dynamoid/adapter/#{Dynamoid::Config.adapter}" unless Dynamoid::Adapter.const_defined?(Dynamoid::Config.adapter.camelcase)
      @adapter = Dynamoid::Adapter.const_get(Dynamoid::Config.adapter.camelcase)
      @adapter.connect! if @adapter.respond_to?(:connect!)
    end
    
    def method_missing(method, *args)
      if @adapter.respond_to?(method)
        start = Time.now
        result = @adapter.send(method, *args)
        Dynamoid.logger.info "(#{((Time.now - start) * 1000.0).round(2)} ms) #{method.to_s.split('_').collect(&:upcase).join(' ')}#{ " - #{args.join(',')}" unless args.empty? }"
        return result
      end
      super
    end
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dynamoid-0.1.1 lib/dynamoid/adapter.rb
dynamoid-0.1.0 lib/dynamoid/adapter.rb
dynamoid-0.0.7 lib/dynamoid/adapter.rb
dynamoid-0.0.6 lib/dynamoid/adapter.rb
dynamoid-0.0.5 lib/dynamoid/adapter.rb