Module: Dynamoid::Adapter
- Extended by:
- Adapter
- Included in:
- Adapter
- Defined in:
- lib/dynamoid/adapter.rb,
lib/dynamoid/adapter/local.rb,
lib/dynamoid/adapter/aws_sdk.rb
Defined Under Namespace
Modules: AwsSdk, Local
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/dynamoid/adapter.rb', line 18
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
|
Instance Method Details
#adapter ⇒ Object
7
8
9
10
|
# File 'lib/dynamoid/adapter.rb', line 7
def adapter
reconnect! unless @adapter
@adapter
end
|
#reconnect! ⇒ Object
12
13
14
15
16
|
# File 'lib/dynamoid/adapter.rb', line 12
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
|