Class: SDBTools::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/sdbtools/database.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_key = nil, secret_key = nil, options = {}) ⇒ Database

Returns a new instance of Database.



6
7
8
9
10
11
12
# File 'lib/sdbtools/database.rb', line 6

def initialize(access_key=nil, secret_key=nil, options={})
  @logger = (options[:logger] ||= ::Logger.new($stderr))
  @sdb    =         MeasuredSdbInterface.new(
    options.delete(:sdb_interface) {
      Aws::SdbInterface.new(access_key, secret_key, options)
    })
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



4
5
6
# File 'lib/sdbtools/database.rb', line 4

def logger
  @logger
end

#sdbObject (readonly)

Returns the value of attribute sdb.



3
4
5
# File 'lib/sdbtools/database.rb', line 3

def sdb
  @sdb
end

Instance Method Details

#create_domain(domain_name) ⇒ Object



30
31
32
33
# File 'lib/sdbtools/database.rb', line 30

def create_domain(domain_name)
  @sdb.create_domain(domain_name)
  domain(domain_name)
end

#delete_domain(domain_name) ⇒ Object



35
36
37
# File 'lib/sdbtools/database.rb', line 35

def delete_domain(domain_name)
  @sdb.delete_domain(domain_name)
end

#domain(domain_name) ⇒ Object



22
23
24
# File 'lib/sdbtools/database.rb', line 22

def domain(domain_name)
  Domain.new(@sdb, domain_name)
end

#domain_exists?(domain_name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sdbtools/database.rb', line 26

def domain_exists?(domain_name)
  domains.include?(domain_name)
end

#domainsObject



14
15
16
17
18
19
20
# File 'lib/sdbtools/database.rb', line 14

def domains
  domains_op = Operation.new(@sdb, :list_domains, nil)
  domains_op.inject([]) {|domains, (results, operation)|
    domains.concat(results[:domains])
    domains
  }
end

#make_dump(domain, filename) ⇒ Object



39
40
41
# File 'lib/sdbtools/database.rb', line 39

def make_dump(domain, filename)
  Dump.new(domain, filename, @logger)
end

#make_load(domain, filename) ⇒ Object



43
44
45
# File 'lib/sdbtools/database.rb', line 43

def make_load(domain, filename)
  Load.new(domain, filename, @logger)
end