Class RightAws::ActiveSdb
In: lib/sdb/active_sdb.rb
Parent: Object
RuntimeError AwsError AwsNoChange RightAWSParser RightErrorResponseParser RightHttp2xxParser AcfInterface SqsInterface SqsGen2Interface S3Interface Ec2 SdbInterface RightAwsBase ActiveSdbConnect ActiveSdb SqsGen2 S3 S3Generator Sqs RightDummyParser AWSErrorHandler AwsBenchmarkingBlock AwsUtils RightSaxParserCallback lib/sqs/right_sqs_interface.rb lib/sqs/right_sqs_gen2.rb lib/s3/right_s3.rb lib/acf/right_acf_interface.rb lib/sqs/right_sqs_gen2_interface.rb lib/sqs/right_sqs.rb lib/sdb/right_sdb_interface.rb lib/sdb/active_sdb.rb lib/ec2/right_ec2.rb lib/s3/right_s3_interface.rb lib/awsbase/right_awsbase.rb RightAwsBaseInterface VERSION RightAws dot/m_13_0.png

RightAws::ActiveSdb — RightScale SDB interface (alpha release)

The RightAws::ActiveSdb class provides a complete interface to Amazon‘s Simple Database Service.

ActiveSdb is in alpha and does not load by default with the rest of RightAws. You must use an additional require statement to load the ActiveSdb class. For example:

  require 'right_aws'
  require 'sdb/active_sdb'

Additionally, the ActiveSdb class requires the ‘uuidtools’ gem; this gem is not normally required by RightAws and is not installed as a dependency of RightAws.

Simple ActiveSdb usage example:

 class Client < RightAws::ActiveSdb::Base
 end

 # connect to SDB
 RightAws::ActiveSdb.establish_connection

 # create domain
 Client.create_domain

 # create initial DB
 Client.create 'name' => 'Bush',     'country' => 'USA',    'gender' => 'male',   'expiration' => '2009', 'post' => 'president'
 Client.create 'name' => 'Putin',    'country' => 'Russia', 'gender' => 'male',   'expiration' => '2008', 'post' => 'president'
 Client.create 'name' => 'Medvedev', 'country' => 'Russia', 'gender' => 'male',   'expiration' => '2012', 'post' => 'president'
 Client.create 'name' => 'Mary',     'country' => 'USA',    'gender' => 'female', 'hobby' => ['patchwork', 'bundle jumping']
 Client.create 'name' => 'Mary',     'country' => 'Russia', 'gender' => 'female', 'hobby' => ['flowers', 'cats', 'cooking']
 sandy_id = Client.create('name' => 'Sandy', 'country' => 'Russia', 'gender' => 'female', 'hobby' => ['flowers', 'cats', 'cooking']).id

 # find all Bushes in USA
 Client.find(:all, :conditions => ["['name'=?] intersection ['country'=?]",'Bush','USA']).each do |client|
   client.reload
   puts client.attributes.inspect
 end

 # find all Maries through the world
 Client.find_all_by_name_and_gender('Mary','female').each do |mary|
   mary.reload
   puts "#{mary[:name]}, gender: #{mary[:gender]}, hobbies: #{mary[:hobby].join(',')}"
 end

 # find new russian president
 medvedev = Client.find_by_post_and_country_and_expiration('president','Russia','2012')
 if medvedev
   medvedev.reload
   medvedev.save_attributes('age' => '42', 'hobby' => 'Gazprom')
 end

 # retire old president
 Client.find_by_name('Putin').delete

 # Sandy disappointed in 'cooking' and decided to hide her 'gender' and 'country' ()
 sandy = Client.find(sandy_id)
 sandy.reload
 sandy.delete_values('hobby' => ['cooking'] )
 sandy.delete_attributes('country', 'gender')

 # remove domain
 Client.delete_domain

Methods

Included Modules

ActiveSdbConnect

Classes and Modules

Module RightAws::ActiveSdb::ActiveSdbConnect
Class RightAws::ActiveSdb::ActiveSdbError
Class RightAws::ActiveSdb::Base

Public Class methods

Create new domain. Raises no errors if the domain already exists.

 RightAws::ActiveSdb.create_domain('alpha')  #=> {:request_id=>"6fc652a0-0000-41d5-91f4-3ed390a3d3b2", :box_usage=>"0.0055590278"}

[Source]

     # File lib/sdb/active_sdb.rb, line 136
136:       def create_domain(domain_name)
137:         connection.create_domain(domain_name)
138:       end

Remove domain from SDB. Raises no errors if the domain does not exist.

 RightAws::ActiveSdb.create_domain('alpha')  #=> {:request_id=>"6fc652a0-0000-41c6-91f4-3ed390a3d3b2", :box_usage=>"0.0055590001"}

[Source]

     # File lib/sdb/active_sdb.rb, line 145
145:       def delete_domain(domain_name)
146:         connection.delete_domain(domain_name)
147:       end

Retreive a list of domains.

 put RightAws::ActiveSdb.domains #=> ['co-workers','family','friends','clients']

[Source]

     # File lib/sdb/active_sdb.rb, line 127
127:       def domains
128:         connection.list_domains[:domains]
129:       end

[Validate]