class AWS::SimpleDB::ItemData

Holds the data for a SimpleDB item. While {Item} only proxies requests to return data, this class actually stores data returned by a query. For example, you can use this to get the list of items whose titles are palindromes using only a single request to SimpleDB (not counting pagination):

items.enum_for(:select).
  select { |data| data.title == data.title.to_s.reverse }.
  map { |data| data.item }

The {AWS::SimpleDB::ItemCollection#select} call yields instances of ItemData, and the map call in the example above gets the list of corresponding {Item} instances.

Attributes

attributes[R]

@return [Hash] A hash of attribute names to arrays of values.

domain[R]

@return [Domain] The domain from which the item data was retrieved.

name[R]

@return [String] The item name.

Public Class Methods

new(opts = {}) click to toggle source

@private

# File lib/aws/simple_db/item_data.rb, line 33
def initialize(opts = {})
  @name = opts[:name]
  @attributes = opts[:attributes]
  @domain = opts[:domain]

  if obj = opts[:response_object]
    @name ||= obj.name if obj.respond_to?(:name)
    if obj.respond_to?(:attributes)
      @attributes ||= obj.attributes.inject({}) do |m, att|
        m[att.name] ||= []
        m[att.name] << att.value
        m
      end
    end
  end
end

Public Instance Methods

item() click to toggle source

Returns the {Item} corresponding to this ItemData; you can use this to perform further operations on the item, or to fetch its most recent data. @return [Item] The item this data belongs to.

# File lib/aws/simple_db/item_data.rb, line 63
def item
  domain.items[name]
end