Used to build a batch of updates to an item’s attributes. See {AWS::DynamoDB::AttributeCollection#update} for more information.
@private
@private
# File lib/aws/dynamo_db/attribute_collection.rb, line 238 def initialize @updates = {} end
Adds to the values of one or more attributes. See {AWS::DynamoDB::AttributeCollection#add} for more information.
# File lib/aws/dynamo_db/attribute_collection.rb, line 262 def add attributes attribute_updates("ADD", attributes) end
Deletes one or more attributes or attribute values. See {AWS::DynamoDB::AttributeCollection#delete} for more information.
# File lib/aws/dynamo_db/attribute_collection.rb, line 269 def delete *args if args.first.kind_of?(Hash) attribute_updates("DELETE", args.shift, :setify => true) else add_updates(args.inject({}) do |u, name| u.update(name.to_s => { :action => "DELETE" }) end) end end
Replaces the values of one or more attributes. See {AWS::DynamoDB::AttributeCollection#set} for more information.
# File lib/aws/dynamo_db/attribute_collection.rb, line 244 def set attributes to_delete = [] attributes = attributes.inject({}) do |attributes, (name, value)| if value == nil to_delete << name else attributes[name] = value end attributes end attribute_updates("PUT", attributes) delete(*to_delete) end