Skip to content

Instantly share code, notes, and snippets.

@karmi
Created November 11, 2009 15:10
Show Gist options
  • Save karmi/232016 to your computer and use it in GitHub Desktop.
Save karmi/232016 to your computer and use it in GitHub Desktop.
Ultra minimal Ruby interface to CouchDB with HTTParty
require 'rubygems'
require 'httparty'
require 'ostruct'
class Post < OpenStruct
def self.database_name; "sofa"; end
include HTTParty
format :json
base_uri "localhost:5984/#{database_name}"
def self.find(id)
new get('/'+id)
end
end
post = Post.find('New-post')
puts post.title
puts post.tags.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment