lib/dynamoid/adapter.rb in dynamoid-1.1.0 vs lib/dynamoid/adapter.rb in dynamoid-1.2.0
- old
+ new
@@ -15,11 +15,11 @@
@tables_ = Concurrent::Atom.new(nil)
end
def tables
if !@tables_.value
- @tables_.swap{|value, args| benchmark('Cache Tables') {list_tables}}
+ @tables_.swap{|value, args| benchmark('Cache Tables') { list_tables } }
end
@tables_.value
end
# The actual adapter currently in use.
@@ -129,10 +129,19 @@
benchmark('Create Table') { adapter.create_table(table_name, key, options) }
tables << table_name
end
end
- [:batch_get_item, :delete_item, :delete_table, :get_item, :list_tables, :put_item].each do |m|
+ # @since 0.2.0
+ def delete_table(table_name, *args)
+ if tables.include?(table_name)
+ benchmark('Delete Table') { adapter.delete_table(table_name, *args) }
+ idx = tables.index(table_name)
+ tables.delete_at(idx)
+ end
+ end
+
+ [:batch_get_item, :delete_item, :get_item, :list_tables, :put_item, :truncate].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|
benchmark("#{m.to_s}", args) {adapter.send(m, *args)}