Class: AWS::SimpleDB::Domain
- Inherits:
-
Object
- Object
- AWS::SimpleDB::Domain
- Defined in:
- lib/aws/simple_db/domain.rb
Overview
Represents a domain in SimpleDB.
Domains, like database tables, must exist before you can write to one.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Returns the name for this domain.
Instance Method Summary collapse
-
#delete ⇒ nil
Deletes the (empty) domain.
-
#delete! ⇒ nil
Deletes the domain and all of its items.
-
#empty? ⇒ Boolean
Returns true if the domain has no items, false otherwise.
-
#exists? ⇒ Boolean
Returns true if this domain exists, false otherwise.
-
#initialize(name, options = {}) ⇒ Domain
constructor
A new instance of Domain.
-
#items ⇒ ItemCollection
Returns a collection that represents all of the items in this domain.
-
#metadata ⇒ DomainMetadata
Returns a metadata object that can provide information about this domain.
Constructor Details
#initialize(name, options = {}) ⇒ Domain
Returns a new instance of Domain.
42 43 44 45 |
# File 'lib/aws/simple_db/domain.rb', line 42 def initialize(name, = {}) super() @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name for this domain.
50 51 52 |
# File 'lib/aws/simple_db/domain.rb', line 50 def name @name end |
Instance Method Details
#delete ⇒ nil
If you need to delete a domain with items, call #delete!
Deletes the (empty) domain.
64 65 66 67 68 69 70 71 |
# File 'lib/aws/simple_db/domain.rb', line 64 def delete unless empty? raise NonEmptyDeleteError, "delete called without :force " + "on a non-empty domain" end client.delete_domain(:domain_name => name) nil end |
#delete! ⇒ nil
Deletes the domain and all of its items.
76 77 78 79 |
# File 'lib/aws/simple_db/domain.rb', line 76 def delete! client.delete_domain(:domain_name => name) nil end |
#empty? ⇒ Boolean
Returns true if the domain has no items, false otherwise.
55 56 57 |
# File 'lib/aws/simple_db/domain.rb', line 55 def empty? .item_count == 0 end |
#exists? ⇒ Boolean
Returns true if this domain exists, false otherwise.
84 85 86 87 88 89 90 91 |
# File 'lib/aws/simple_db/domain.rb', line 84 def exists? begin client.(:domain_name => name) true rescue Errors::NoSuchDomain false end end |
#items ⇒ ItemCollection
Returns a collection that represents all of the items in this domain.
104 105 106 |
# File 'lib/aws/simple_db/domain.rb', line 104 def items ItemCollection.new(self) end |
#metadata ⇒ DomainMetadata
Returns a metadata object that can provide information about this domain.
97 98 99 |
# File 'lib/aws/simple_db/domain.rb', line 97 def DomainMetadata.new(self) end |