def table table, attributes, items, options = {}
table = table.is_a?(Table) ? table.name : table.to_s
attributes = attributes == :all ? nil : [attributes].flatten
keys = items.collect do |item|
case item
when Item then item_key_hash(item)
when Array
{
:hash_key_element => format_attribute_value(item[0]),
:range_key_element => format_attribute_value(item[1]),
}
else
{ :hash_key_element => format_attribute_value(item) }
end
end
if
@request_items.has_key?(table) and
@request_items[table][:attributes_to_get] != attributes
then
msg = "When batch getting attributes, you may only provide " +
"1 list of attributes per table, but the `#{table}` table " +
"has received reqeusts for 2 different sets of attributes"
raise ArgumentError, msg
end
@request_items[table] ||= { :keys => [] }
@request_items[table][:attributes_to_get] = attributes if attributes
@request_items[table][:keys] += keys
@request_items[table].merge!(options)
nil
end