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.
@return [Hash] A hash of attribute names to arrays of values.
@return [Domain] The domain from which the item data was retrieved.
@return [String] The item name.
@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
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