Created
June 1, 2009 18:23
-
-
Save hungryblank/121638 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'aws_sdb_bare' | |
require 'nokogiri' | |
require 'net/http' | |
require 'uuid' | |
include AwsSdb | |
include AwsSdb::Request | |
module HttpHandler | |
def handle | |
Response.parse(Net::HTTP.get(URI.parse(uri))) | |
end | |
end | |
Request::Template.send :include, HttpHandler | |
class Domain | |
class << self | |
def find(name) | |
new(name) | |
end | |
def create!(name) | |
CreateDomain.new(:name => name).handle | |
new(name) | |
end | |
end | |
def initialize(name) | |
@uuid = UUID.new | |
@name = name | |
end | |
def put(attributes) | |
new_id = @uuid.generate(:compact) | |
PutAttributes.new(:domain => @name, :name => new_id, :attributes => attributes).handle | |
new_id | |
end | |
def get(id) | |
response = GetAttributes.new(:domain => @name, :name => id).handle | |
response.attributes | |
end | |
end | |
#== demo == | |
domain = Domain.create!('get_put_test') | |
id = domain.put(:foo => 'bar') | |
p domain.get(id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment