class AWS::SimpleDB::Item

Represents a single item in a SimpleDB domain. You can use this class to delete the item or get its data. You can also use it to access the {AttributeCollection} for the item in order to add, remove, or read the item’s attributes.

item = AWS::SimpleDB.new.domains['mydomain'].items['item-id']

Attributes

domain[R]

@return [Domain] The domain this item belongs to.

name[R]

@return [String] The item name.

Public Class Methods

new(domain, name, options = {}) click to toggle source

@param [Domain] domain The domain the item belongs to @param [String] name The name of the item in SimpleDB. @param [Hash] options

# File lib/aws/simple_db/item.rb, line 33
def initialize domain, name, options = {}
  @domain = domain
  @name = name
  super
end

Public Instance Methods

==(other) click to toggle source
# File lib/aws/simple_db/item.rb, line 82
def == other
  other.is_a?(Item) and 
  other.domain == domain and
  other.name == name
end
Also aliased as: eql?
attributes() click to toggle source

@return [AttributeCollection] A collection representing all attributes

for this item.
# File lib/aws/simple_db/item.rb, line 47
def attributes
  AttributeCollection.new(self)
end
data(options = {}) click to toggle source

Returns all of the item’s attributes in an {ItemData} instance. @return [ItemData] An object with all of the loaded attribute names

and values for this item.
# File lib/aws/simple_db/item.rb, line 73
def data options = {}
  get_opts = {}
  get_opts[:domain_name] = domain.name
  get_opts[:item_name] = name
  get_opts[:consistent_read] = consistent_read(options)
  r = client.get_attributes(get_opts)
  ItemData.new(:name => name, :domain => domain, :response_object => r)
end
delete(options = {}) click to toggle source

Deletes the item and all of its attributes from SimpleDB. @param [Hash] options @option options [Hash] :if Pass a hash with a single key (attribute

name) and a single value (the attribute value).  This causes the
delete to become conditional.

@option options [String,Symbol] :unless Pass an attribute name. This

causes the delete to become conditional on that attribute not
existing.

@return [nil]

# File lib/aws/simple_db/item.rb, line 60
def delete options = {}
  delete_opts = {}
  delete_opts[:domain_name] = domain.name
  delete_opts[:item_name] = name
  delete_opts[:expected] = expect_condition_opts(options)
  delete_opts.delete(:expected) if delete_opts[:expected].empty?
  client.delete_attributes(delete_opts)
  nil
end
eql?(other) click to toggle source
Alias for: ==