Class: AWS::SimpleDB::DomainCollection
- Inherits:
-
Object
- Object
- AWS::SimpleDB::DomainCollection
- Includes:
- Core::Model, Enumerable
- Defined in:
- lib/aws/simple_db/domain_collection.rb
Overview
An Enumerable collection representing all your domains in SimpleDB.
Use a DomainCollection to create, get and list domains.
Instance Attribute Summary
Attributes included from Core::Model
Instance Method Summary collapse
-
#[](domain_name) ⇒ Domain
Returns a domain object with the given name.
-
#create(domain_name) ⇒ Domain
Creates a domain in SimpleDB and returns a domain object.
- #each(options = {}) {|domain| ... } ⇒ nil
Methods included from Core::Model
#client, #config_prefix, #initialize, #inspect
Instance Method Details
#[](domain_name) ⇒ Domain
This does not attempt to create the domain if it does not already exist in SimpleDB. Use #create to add a domain to SDB.
Returns a domain object with the given name.
63 64 65 |
# File 'lib/aws/simple_db/domain_collection.rb', line 63 def [] domain_name domain_named(domain_name) end |
#create(domain_name) ⇒ Domain
This operation might take 10 or more seconds to complete.
Creating a domain in SimpleDB is an idempotent operation; running it multiple times using the same domain name will not result in an error.
You can create up to 100 domains per account.
Creates a domain in SimpleDB and returns a domain object.
51 52 53 54 |
# File 'lib/aws/simple_db/domain_collection.rb', line 51 def create(domain_name) client.create_domain(:domain_name => domain_name) domain_named(domain_name) end |
#each(options = {}) {|domain| ... } ⇒ nil
Normally your account has a limit of 100 SimpleDB domains. You can request more here
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/aws/simple_db/domain_collection.rb', line 76 def each = {}, &block total_limit = [:limit] batch_size = [:batch_size] || 100 received = 0 next_token = nil begin limit = total_limit ? [total_limit - received, batch_size].min : batch_size = { :max_number_of_domains => limit } [:next_token] = next_token if next_token list = client.list_domains() next_token = list[:next_token] received += list[:domain_names].size list[:domain_names].each do |name| yield(domain_named(name)) end end while next_token and (total_limit.nil? or received < total_limit) nil end |