Class: SafeAWS::SimpleDB

Inherits:
Object
  • Object
show all
Defined in:
lib/SafeAWS/SimpleDB.rb

Overview

Wrap SimpleDB functions that we use. Catch errors and do something reasonable.

Instance Method Summary collapse

Constructor Details

#initialize(access_key, secret_key) ⇒ SimpleDB

Returns a new instance of SimpleDB.



12
13
14
15
# File 'lib/SafeAWS/SimpleDB.rb', line 12

def initialize(access_key, secret_key)
  @simple_db = AWS::SimpleDB.new(access_key, secret_key)
  @@log = STDOUT
end

Instance Method Details

#create_domain(domain_name) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/SafeAWS/SimpleDB.rb', line 39

def create_domain(domain_name)
  begin
    @simple_db.create_domain(domain_name)
  rescue
    report_error false
  end
end

#delete_attributes(domain_name, item_name, attributes = {}) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/SafeAWS/SimpleDB.rb', line 63

def delete_attributes(domain_name, item_name, attributes = {})
  begin
    @simple_db.delete_attributes(domain_name, item_name, attributes)
  rescue
    report_error false
  end
end

#delete_domain(domain_name) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/SafeAWS/SimpleDB.rb', line 47

def delete_domain(domain_name)
  begin
    @simple_db.delete_domain(domain_name)
  rescue
    report_error false
  end
end

#get_attributes(domain_name, item_name, attribute_name = nil) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/SafeAWS/SimpleDB.rb', line 71

def get_attributes(domain_name, item_name, attribute_name = nil)
  begin
    @simple_db.get_attributes(domain_name, item_name, attribute_name)
  rescue
    report_error {}
  end
end

#list_domains(max_domains = 100) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/SafeAWS/SimpleDB.rb', line 31

def list_domains(max_domains = 100)
  begin
    @simple_db.list_domains(max_domains)
  rescue
    report_error []
  end
end

#logger=(logger) ⇒ Object



17
18
19
# File 'lib/SafeAWS/SimpleDB.rb', line 17

def logger=(logger)
  @@log = logger
end

#put_attributes(domain_name, item_name, attributes, replace = false) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/SafeAWS/SimpleDB.rb', line 55

def put_attributes(domain_name, item_name, attributes, replace=false)
  begin
    @simple_db.put_attributes(domain_name, item_name, attributes, replace)
  rescue
    report_error false
  end
end

#query(domain_name, query_expression = nil, options = {:fetch_all=>true}) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/SafeAWS/SimpleDB.rb', line 79

def query(domain_name, query_expression=nil, options={:fetch_all=>true})
  begin
    @simple_db.query(domain_name, query_expression, options)
  rescue
    report_error {}
  end
end