Created
February 11, 2010 21:18
-
-
Save johnthethird/301963 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
test.rb | |
----------------------------------- | |
#!/usr/local/bin/ruby | |
require 'ripple' | |
# Create a client interface | |
client = Riak::Client.new | |
# Retrieve a bucket | |
bucket = client.bucket("doc") # a Riak::Bucket | |
new_one = Riak::RObject.new(bucket, "application.js") | |
new_one.content_type = "application/javascript" # You must set the content type. | |
new_one.data = "alert('Hello, World!')" | |
new_one.store | |
# Get an object from the bucket | |
object = bucket.get("application.js") # a Riak::RObject | |
puts object.inspect | |
class Email | |
include Ripple::Document | |
property :from, String, :presence => true | |
property :to, String, :presence => true | |
property :sent, Time, :default => proc { Time.now } | |
property :body, String | |
end | |
email = Email.find("37458abc752f8413e") # GET /raw/emails/37458abc752f8413e | |
email.from = "someone@nowhere.net" | |
email.save # PUT /raw/emails/37458abc752f8413e | |
reply = Email.new | |
reply.from = "justin@bashoooo.com" | |
reply.to = "sean@geeemail.com" | |
reply.body = "Riak is a good fit for scalable Ruby apps." | |
reply.save | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment