class AWS::SimpleDB::Domain

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

Attributes

name[R]

Returns the name for this domain.

@return [String] The name of this domain.

Public Class Methods

new(name, options = {}) click to toggle source

@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

Public Instance Methods

==(other) click to toggle source

@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
Also aliased as: eql?
delete() click to toggle source

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
delete!() click to toggle source

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
empty?() click to toggle source

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
eql?(other) click to toggle source
Alias for: ==
exists?() click to toggle source

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
inspect() click to toggle source

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
items() click to toggle source

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
metadata() click to toggle source

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