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 {ItemCollection#select} call yields instances of ItemData, and the `map` call in the example above gets the list of corresponding {Item} instances.
Attributes
@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.
Public Class Methods
@api 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[:attributes] @attributes ||= begin attributes = {} obj[:attributes].each do |attr| attributes[attr[:name]] ||= [] attributes[attr[:name]] << attr[:value] end attributes end end end end
Public Instance Methods
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 66 def item domain.items[name] end