def create attributes, options = {}
table.assert_schema!
attributes = attributes.inject({}) do |hash, (key, value)|
context = "value for attribute #{key}"
hash.update(key.to_s => format_attribute_value(value, context))
end
client_opts = {
:table_name => table.name,
:item => attributes
}
expected = expect_conditions(options)
client_opts[:expected] = expected unless expected.empty?
client_opts[:return_values] = options[:return].to_s.upcase if
options[:return]
resp = client.put_item(client_opts)
item = Item.new_from(:put_item, attributes, table)
if options[:return]
values_from_response_hash(resp.data["Attributes"])
else
item
end
end