lib/dynamoid/adapter.rb in dynamoid-3.7.1 vs lib/dynamoid/adapter.rb in dynamoid-3.8.0
- old
+ new
@@ -1,13 +1,10 @@
# 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 'concurrent/atom'
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.
# 2) Allows switching `config.adapter` to ease development of a new adapter.
# 3) Caches the list of tables Dynamoid knows about.
@@ -42,11 +39,11 @@
@tables_.swap { |_value, _args| nil }
end
# Shows how long it takes a method to run on the adapter. Useful for generating logged output.
#
- # @param [Symbol] method the name of the method to appear in the log
+ # @param [Symbol|String] method the name of the method to appear in the log
# @param [Array] args the arguments to the method to appear in the log
# @yield the actual code to benchmark
#
# @return the result of the yield
#
@@ -76,11 +73,11 @@
# depending on whether ids is a range or a single key.
# If a range key is present, it will also interpolate that into the ids so
# that the batch get will acquire the correct record.
#
# @param [String] table the name of the table to write the object to
- # @param [Array] ids to fetch, can also be a string of just one id
+ # @param [String, Array] ids to fetch; can also be a string of just one id
# @param [Hash] options Passed to the underlying query. The :range_key option is required whenever the table has a range key,
# unless multiple ids are passed in.
#
# @since 0.2.0
def read(table, ids, options = {}, &blk)
@@ -92,11 +89,11 @@
end
# Delete an item from a table.
#
# @param [String] table the name of the table to write the object to
- # @param [Array] ids to delete, can also be a string of just one id
+ # @param [String, Array] ids to delete; can also be a string of just one id
# @param [Hash] options allowed only +range_key+ - range key or array of
# range keys of the record to delete, can also be
# a string of just one range_key, and +conditions+
#
def delete(table, ids, options = {})
@@ -148,10 +145,10 @@
%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|
- benchmark(m.to_s, *args) { adapter.send(m, *args, &blk) }
+ benchmark(m, *args) { adapter.send(m, *args, &blk) }
end
end
# Delegate all methods that aren't defind here to the underlying adapter.
#