You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::SimpleDB::Domain

Inherits:
Object
  • Object
show all
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.

Examples:

Creating a domain


domain = SimpleDB.new.domains.create('mydomain')

Getting a domain


domain = SimpleDB.new.domains['mydomain']

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Domain

Returns a new instance of Domain

Parameters:

  • name (String)

    The name of a SimpleDB domain to reference.



39
40
41
42
# File 'lib/aws/simple_db/domain.rb', line 39

def initialize(name, options = {})
  super(options)
  @name = name
end

Instance Attribute Details

#nameString (readonly)

Returns the name for this domain.

Returns:

  • (String)

    The name of this domain.



47
48
49
# File 'lib/aws/simple_db/domain.rb', line 47

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Returns true if the domains are the same.

Returns:

  • (Boolean)

    Returns true if the domains are the same.



106
107
108
109
110
# File 'lib/aws/simple_db/domain.rb', line 106

def == other
  other.is_a?(Domain) and
  other.name == name and
  other.config.simple_db_endpoint == config.simple_db_endpoint
end

#deletenil

Note:

If you need to delete a domain with items, call #delete!

Deletes the (empty) domain.

Returns:

  • (nil)

Raises:

  • (NonEmptyDeleteError)

    Raises if the domain is not empty.



61
62
63
64
65
66
67
68
# File 'lib/aws/simple_db/domain.rb', line 61

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.

Returns:

  • (nil)


73
74
75
76
# File 'lib/aws/simple_db/domain.rb', line 73

def delete!
  client.delete_domain(:domain_name => name)
  nil
end

#empty?Boolean

Returns true if the domain has no items, false otherwise.

Returns:

  • (Boolean)

    Returns true if the domain has no items.



52
53
54
# File 'lib/aws/simple_db/domain.rb', line 52

def empty?
  .item_count == 0
end

#exists?Boolean

Returns true if this domain exists, false otherwise.

Returns:

  • (Boolean)

    Returns true if the domain exists.



81
82
83
84
85
86
87
88
# File 'lib/aws/simple_db/domain.rb', line 81

def exists?
  begin
    client.(:domain_name => name)
    true
  rescue Errors::NoSuchDomain
    false
  end
end

#itemsItemCollection

Returns a collection that represents all of the items in this domain.

Returns:



101
102
103
# File 'lib/aws/simple_db/domain.rb', line 101

def items
  ItemCollection.new(self)
end

#metadataDomainMetadata

Returns a metadata object that can provide information about this domain.

Returns:



94
95
96
# File 'lib/aws/simple_db/domain.rb', line 94

def 
  DomainMetadata.new(self)
end