Class: Stackster::AWS::SimpleDB
- Inherits:
-
Object
- Object
- Stackster::AWS::SimpleDB
- Defined in:
- lib/stackster/aws/simpledb.rb
Instance Method Summary collapse
- #create_domain(domain) ⇒ Object
- #delete(domain, key) ⇒ Object
- #domain_exists?(domain) ⇒ Boolean
- #domains ⇒ Object
-
#initialize(args) ⇒ SimpleDB
constructor
A new instance of SimpleDB.
- #put_attributes(domain, key, attributes, options) ⇒ Object
- #select(query) ⇒ Object
Constructor Details
#initialize(args) ⇒ SimpleDB
Returns a new instance of SimpleDB.
7 8 9 10 11 12 |
# File 'lib/stackster/aws/simpledb.rb', line 7 def initialize(args) c = args[:config] @connect = Fog::AWS::SimpleDB.new :aws_access_key_id => c.access_key, :aws_secret_access_key => c.secret_key, :region => c.region end |
Instance Method Details
#create_domain(domain) ⇒ Object
22 23 24 |
# File 'lib/stackster/aws/simpledb.rb', line 22 def create_domain(domain) @connect.create_domain(domain) unless domain_exists?(domain) end |
#delete(domain, key) ⇒ Object
46 47 48 |
# File 'lib/stackster/aws/simpledb.rb', line 46 def delete(domain, key) @connect.delete_attributes domain, key end |
#domain_exists?(domain) ⇒ Boolean
18 19 20 |
# File 'lib/stackster/aws/simpledb.rb', line 18 def domain_exists?(domain) domains.include? domain end |
#domains ⇒ Object
14 15 16 |
# File 'lib/stackster/aws/simpledb.rb', line 14 def domains @connect.list_domains.body['Domains'] end |
#put_attributes(domain, key, attributes, options) ⇒ Object
26 27 28 |
# File 'lib/stackster/aws/simpledb.rb', line 26 def put_attributes(domain, key, attributes, ) @connect.put_attributes domain, key, attributes, end |
#select(query) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/stackster/aws/simpledb.rb', line 30 def select(query) = { 'ConsistentRead' => true } data = {} next_token = nil while true .merge! 'NextToken' => next_token chunk = @connect.select(query, ).body data.merge! chunk['Items'] next_token = chunk['NextToken'] break unless next_token end data end |