Represents a domain in SimpleDB.
Domains, like database tables, must exist before you can write to one.
@example Creating a domain
domain = SimpleDB.new.domains.create('mydomain')
@example Getting a domain
domain = SimpleDB.new.domains['mydomain']
@see DomainCollection
Returns the name for this domain.
@return [String] The name of this domain.
@param [String] The name of a SimpleDB domain to reference.
# File lib/aws/simple_db/domain.rb, line 37 def initialize(name, options = {}) super(options) @name = name end
@return [Boolean] Returns true if the domains are the same.
# 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
Deletes the (empty) domain.
@note If you need to delete a domain with items, call {delete!} @raise [NonEmptyDeleteError] Raises if the domain is not empty. @return [nil]
# 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
Deletes the domain and all of its items.
@return [nil]
# File lib/aws/simple_db/domain.rb, line 71 def delete! client.delete_domain(:domain_name => name) nil end
Returns true if the domain has no items, false otherwise.
@return [Boolean] Returns true if the domain has no items.
# File lib/aws/simple_db/domain.rb, line 50 def empty? metadata.item_count == 0 end
Returns true if this domain exists, false otherwise.
@return [Boolean] Returns true if the domain exists.
# File lib/aws/simple_db/domain.rb, line 79 def exists? begin client.domain_metadata(:domain_name => name) true rescue Errors::NoSuchDomain false end end
An irb-friendly string representation of this object.
@return [String] @private
# File lib/aws/simple_db/domain.rb, line 115 def inspect "#<#{self.class}:#{name}>" end
Returns a collection that represents all of the items in this domain.
@return [ItemCollection]
# File lib/aws/simple_db/domain.rb, line 99 def items ItemCollection.new(self) end
Returns a metadata object that can provide information about this domain.
@return [DomainMetadata]
# File lib/aws/simple_db/domain.rb, line 92 def metadata DomainMetadata.new(self) end