lib/dynamoid/adapter.rb in dynamoid-3.2.0 vs lib/dynamoid/adapter.rb in dynamoid-3.3.0

- old
+ new

@@ -1,10 +1,11 @@ # frozen_string_literal: true # require only 'concurrent/atom' once this issue is resolved: # https://github.com/ruby-concurrency/concurrent-ruby/pull/377 require 'concurrent' +require "dynamoid/adapter_plugin/aws_sdk_v3" # encoding: utf-8 module Dynamoid # Adapter's value-add: # 1) For the rest of Dynamoid, the gateway to DynamoDB. @@ -27,11 +28,11 @@ # # @since 0.2.0 def adapter unless @adapter_.value adapter = self.class.adapter_plugin_class.new - adapter.connect! if adapter.respond_to?(:connect!) + adapter.connect! @adapter_.compare_and_set(nil, adapter) clear_cache! end @adapter_.value end @@ -140,15 +141,11 @@ %i[batch_get_item delete_item get_item list_tables put_item truncate batch_write_item batch_delete_item].each do |m| # Method delegation with benchmark to the underlying adapter. Faster than relying on method_missing. # # @since 0.2.0 define_method(m) do |*args, &blk| - if blk.present? - benchmark(m.to_s, *args) { adapter.send(m, *args, &blk) } - else - benchmark(m.to_s, *args) { adapter.send(m, *args) } - end + benchmark(m.to_s, *args) { adapter.send(m, *args, &blk) } end end # Delegate all methods that aren't defind here to the underlying adapter. # @@ -177,13 +174,9 @@ def query(table_name, opts = {}) adapter.query(table_name, opts) end def self.adapter_plugin_class - unless Dynamoid.const_defined?(:AdapterPlugin) && Dynamoid::AdapterPlugin.const_defined?(Dynamoid::Config.adapter.camelcase) - require "dynamoid/adapter_plugin/#{Dynamoid::Config.adapter}" - end - Dynamoid::AdapterPlugin.const_get(Dynamoid::Config.adapter.camelcase) end end end