4 CouchObject is a set of classes to help you talk to CouchDb (http://couchdbwiki.com/) with Ruby.
7 include CouchObject::Persistable
18 def self.from_couch(attributes)
19 new(attributes["wheels"])
23 By including the CouchObject::Persistable and defining two methods on our class we specify how we should serialize and deserialize our object to and from a CouchDb:
25 >> bike_4wd = Bike.new(4)
26 => #<Bike:0x6a0a68 @wheels=4>
27 >> bike_4wd.save("couchobject")
28 => {"_rev"=>1745167971, "_id"=>"6FA2AFB623A93E0E77DEAAF59BB02565", "ok"=>true}
29 >> bike = Bike.get_by_id("couchobject", bike_4wd.id)
30 => #<Bike:0x64846c @wheels=4>