Class: AWS::SimpleDB::Attribute
- Inherits:
-
Object
- Object
- AWS::SimpleDB::Attribute
- Includes:
- Enumerable
- Defined in:
- lib/aws/simple_db/attribute.rb
Overview
Represents a single named item attribute in SimpleDB.
Instance Attribute Summary collapse
-
#item ⇒ Item
readonly
The item this attribute belongs to.
-
#name ⇒ String
readonly
The name of this attribute.
Instance Method Summary collapse
-
#add(*values) ⇒ nil
(also: #<<)
Appends values to this attribute.
-
#delete(*values) ⇒ nil
Deletes this attribute or specific values from this attribute.
-
#each(options = {}) {|attribute_value| ... } ⇒ nil
Yields once for each value on this attribute.
-
#set(*values) ⇒ nil
Sets all values for this attribute, replacing current values.
-
#values(options = {}) ⇒ Array<String>
Returns all values for this attribute as an array of strings.
Instance Attribute Details
#item ⇒ Item (readonly)
Returns The item this attribute belongs to.
39 40 41 |
# File 'lib/aws/simple_db/attribute.rb', line 39 def item @item end |
#name ⇒ String (readonly)
Returns The name of this attribute.
42 43 44 |
# File 'lib/aws/simple_db/attribute.rb', line 42 def name @name end |
Instance Method Details
#add(*values) ⇒ nil Also known as: <<
Appends values to this attribute. Duplicate values are ignored by SimpleDB.
72 73 74 75 |
# File 'lib/aws/simple_db/attribute.rb', line 72 def add *values put(values, false) nil end |
#delete(*values) ⇒ nil
Deletes this attribute or specific values from this attribute.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/aws/simple_db/attribute.rb', line 92 def delete *values expect_opts = values.pop if values.last.kind_of?(Hash) if values.empty? delete_named_attributes(name, expect_opts || {}) else delete_attribute_values(Hash[[[name, values]]]. merge(expect_opts || {})) end nil end |
#each(options = {}) {|attribute_value| ... } ⇒ nil
Yields once for each value on this attribute.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/aws/simple_db/attribute.rb', line 113 def each = {}, &block resp = client.get_attributes( :domain_name => item.domain.name, :item_name => item.name, :attribute_names => [name], :consistent_read => consistent_read()) resp.attributes.each do |attribute| yield(attribute.value) end nil end |
#set(*values) ⇒ nil
Sets all values for this attribute, replacing current values.
54 55 56 57 |
# File 'lib/aws/simple_db/attribute.rb', line 54 def set *values put(values, true) nil end |
#values(options = {}) ⇒ Array<String>
Returns all values for this attribute as an array of strings.
140 141 142 143 144 145 146 |
# File 'lib/aws/simple_db/attribute.rb', line 140 def values = {} values = [] self.each() do |value| values << value end values end |