Skip to content

Instantly share code, notes, and snippets.

View philharvey's full-sized avatar

Phil Harvey philharvey

  • Nashville, TN
View GitHub Profile
class Blog
include MongoMapper::Document
# Attributes ::::::::::::::::::::::::::::::::::::::::::::::::::::::
key :title, String
key :category_id, ObjectId
key :archive_after, Time
# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
belongs_to :category
@JonKernPA
JonKernPA / idea.rb
Created August 4, 2010 18:00
This shows A User/Idea/Rating model using MongoMapper
class Idea
include MongoMapper::Document
key :brilliance, String, :default => "Dark Matter Sucks!"
many :ratings
belongs_to :user
key :user_id, ObjectId
def to_s
text = "#{user.name} had this IDEA: #{brilliance}\n\tRATINGS:\n"
ratings.each do |r|
function I(x) { return x; }
function walk(obj, pre, post) {
var k, v;
obj = (pre||I)(obj);
if (typeof(obj) === 'object') {
for (k in obj) if (obj.hasOwnProperty(k)) {
v = (post||I)(walk(obj[k], pre, post));
if (v === undefined) {
delete obj[k];