Skip to content

Instantly share code, notes, and snippets.

@wasnotrice
Created May 21, 2009 14:59
Show Gist options
  • Select an option

  • Save wasnotrice/115502 to your computer and use it in GitHub Desktop.

Select an option

Save wasnotrice/115502 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'couchrest'
class Doc < CouchRest::ExtendedDocument
property :normal_property
property :casted_model, :cast_as => 'CastedModel'
end
class CastedModel < Hash
include CouchRest::CastedModel
end
doc = Doc.new
[:normal_property, :casted_model].each do |prop|
print "#{prop} is "
puts doc.send(prop).nil? ? "nil" : "a #{doc.send(prop).class}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment