Skip to content

Instantly share code, notes, and snippets.

@johnthethird
Created February 11, 2010 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnthethird/301963 to your computer and use it in GitHub Desktop.
Save johnthethird/301963 to your computer and use it in GitHub Desktop.
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