Class: AWS::SimpleDB::ItemData
- Inherits:
-
Object
- Object
- AWS::SimpleDB::ItemData
- Defined in:
- lib/aws/simple_db/item_data.rb
Overview
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.
Instance Attribute Summary collapse
-
#attributes ⇒ Hash
readonly
A hash of attribute names to arrays of values.
-
#domain ⇒ Domain
readonly
The domain from which the item data was retrieved.
-
#name ⇒ String
readonly
The item name.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ ItemData
constructor
A new instance of ItemData.
-
#item ⇒ Item
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.
Constructor Details
#initialize(opts = {}) ⇒ ItemData
Returns a new instance of ItemData.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 |
Instance Attribute Details
#attributes ⇒ Hash (readonly)
Returns A hash of attribute names to arrays of values.
57 58 59 |
# File 'lib/aws/simple_db/item_data.rb', line 57 def attributes @attributes end |
#domain ⇒ Domain (readonly)
Returns The domain from which the item data was retrieved.
60 61 62 |
# File 'lib/aws/simple_db/item_data.rb', line 60 def domain @domain end |
#name ⇒ String (readonly)
Returns The item name.
54 55 56 |
# File 'lib/aws/simple_db/item_data.rb', line 54 def name @name end |
Instance Method Details
#item ⇒ Item
Returns the AWS::SimpleDB::Item corresponding to this ItemData; you can use this to perform further operations on the item, or to fetch its most recent data.
66 67 68 |
# File 'lib/aws/simple_db/item_data.rb', line 66 def item domain.items[name] end |