Class: AWS::SimpleDB::Domain
- Inherits:
-
Object
- Object
- AWS::SimpleDB::Domain
- Includes:
- Core::Model
- 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.
Defined Under Namespace
Classes: NonEmptyDeleteError
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Returns the name for this domain.
Attributes included from Core::Model
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Returns true if the domains are the same.
-
#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.
-
#inspect ⇒ String
An irb-friendly string representation of this object.
-
#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.
Methods included from Core::Model
Constructor Details
#initialize(name, options = {}) ⇒ Domain
Returns a new instance of Domain.
37 38 39 40 |
# File 'lib/aws/simple_db/domain.rb', line 37 def initialize(name, = {}) super() @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name for this domain.
45 46 47 |
# File 'lib/aws/simple_db/domain.rb', line 45 def name @name end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Returns true if the domains are the same.
104 105 106 107 108 |
# File 'lib/aws/simple_db/domain.rb', line 104 def == other other.is_a?(Domain) and other.name == name and other.config.simple_db_endpoint == config.simple_db_endpoint end |
#delete ⇒ nil
If you need to delete a domain with items, call #delete!
Deletes the (empty) domain.
59 60 61 62 63 64 65 66 |
# File 'lib/aws/simple_db/domain.rb', line 59 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.
71 72 73 74 |
# File 'lib/aws/simple_db/domain.rb', line 71 def delete! client.delete_domain(:domain_name => name) nil end |
#empty? ⇒ Boolean
Returns true if the domain has no items, false otherwise.
50 51 52 |
# File 'lib/aws/simple_db/domain.rb', line 50 def empty? .item_count == 0 end |
#exists? ⇒ Boolean
Returns true if this domain exists, false otherwise.
79 80 81 82 83 84 85 86 |
# File 'lib/aws/simple_db/domain.rb', line 79 def exists? begin client.(:domain_name => name) true rescue Errors::NoSuchDomain false end end |
#inspect ⇒ String
An irb-friendly string representation of this object.
115 116 117 |
# File 'lib/aws/simple_db/domain.rb', line 115 def inspect "#<#{self.class}:#{name}>" end |
#items ⇒ ItemCollection
Returns a collection that represents all of the items in this domain.
99 100 101 |
# File 'lib/aws/simple_db/domain.rb', line 99 def items ItemCollection.new(self) end |
#metadata ⇒ DomainMetadata
Returns a metadata object that can provide information about this domain.
92 93 94 |
# File 'lib/aws/simple_db/domain.rb', line 92 def DomainMetadata.new(self) end |