Class: AWS::SimpleDB::Item
- Inherits:
-
Object
- Object
- AWS::SimpleDB::Item
- Includes:
- Core::Model, ConsistentReadOption, ExpectConditionOption
- 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.
Attributes included from Core::Model
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#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.
Methods included from ConsistentReadOption
Methods included from Core::Model
#client, #config_prefix, #inspect
Constructor Details
#initialize(domain, name, options = {}) ⇒ Item
Returns a new instance of Item.
33 34 35 36 37 |
# File 'lib/aws/simple_db/item.rb', line 33 def initialize domain, name, = {} @domain = domain @name = name super end |
Instance Attribute Details
#domain ⇒ Domain (readonly)
Returns The domain this item belongs to.
40 41 42 |
# File 'lib/aws/simple_db/item.rb', line 40 def domain @domain end |
#name ⇒ String (readonly)
Returns The item name.
43 44 45 |
# File 'lib/aws/simple_db/item.rb', line 43 def name @name end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
82 83 84 85 86 |
# File 'lib/aws/simple_db/item.rb', line 82 def == other other.is_a?(Item) and other.domain == domain and other.name == name end |
#attributes ⇒ AttributeCollection
Returns A collection representing all attributes for this item.
47 48 49 |
# File 'lib/aws/simple_db/item.rb', line 47 def attributes AttributeCollection.new(self) end |
#data(options = {}) ⇒ ItemData
Returns all of the item’s attributes in an AWS::SimpleDB::ItemData instance.
73 74 75 76 77 78 79 80 |
# File 'lib/aws/simple_db/item.rb', line 73 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.data) end |
#delete(options = {}) ⇒ nil
Deletes the item and all of its attributes from SimpleDB.
60 61 62 63 64 65 66 67 68 |
# File 'lib/aws/simple_db/item.rb', line 60 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 |