Class: AWS::SimpleDB::Item
- Inherits:
-
Object
- Object
- AWS::SimpleDB::Item
- Defined in:
- lib/aws/simple_db/item.rb
Overview
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']
Instance Attribute Summary collapse
-
#domain ⇒ Domain
readonly
The domain this item belongs to.
-
#name ⇒ String
readonly
The item name.
Instance Method Summary collapse
-
#attributes ⇒ AttributeCollection
A collection representing all attributes for this item.
-
#data(options = {}) ⇒ ItemData
Returns all of the item’s attributes in an ItemData instance.
-
#delete(options = {}) ⇒ nil
Deletes the item and all of its attributes from SimpleDB.
-
#initialize(domain, name, options = {}) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(domain, name, options = {}) ⇒ Item
Returns a new instance of Item.
39 40 41 42 43 |
# File 'lib/aws/simple_db/item.rb', line 39 def initialize domain, name, = {} @domain = domain @name = name super end |
Instance Attribute Details
#domain ⇒ Domain (readonly)
Returns The domain this item belongs to.
46 47 48 |
# File 'lib/aws/simple_db/item.rb', line 46 def domain @domain end |
#name ⇒ String (readonly)
Returns The item name.
49 50 51 |
# File 'lib/aws/simple_db/item.rb', line 49 def name @name end |
Instance Method Details
#attributes ⇒ AttributeCollection
Returns A collection representing all attributes for this item.
53 54 55 |
# File 'lib/aws/simple_db/item.rb', line 53 def attributes AttributeCollection.new(self) end |
#data(options = {}) ⇒ ItemData
Returns all of the item’s attributes in an AWS::SimpleDB::ItemData instance.
72 73 74 75 76 77 78 79 |
# File 'lib/aws/simple_db/item.rb', line 72 def data = {} get_opts = {} get_opts[:domain_name] = domain.name get_opts[:item_name] = name get_opts[:consistent_read] = consistent_read() r = client.get_attributes(get_opts) ItemData.new(:name => name, :domain => domain, :response_object => r) end |
#delete(options = {}) ⇒ nil
Deletes the item and all of its attributes from SimpleDB.
59 60 61 62 63 64 65 66 67 |
# File 'lib/aws/simple_db/item.rb', line 59 def delete = {} delete_opts = {} delete_opts[:domain_name] = domain.name delete_opts[:item_name] = name delete_opts[:expected] = expect_condition_opts() delete_opts.delete(:expected) if delete_opts[:expected].empty? client.delete_attributes(delete_opts) nil end |