This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Blog | |
| include MongoMapper::Document | |
| # Attributes :::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| key :title, String | |
| key :category_id, ObjectId | |
| key :archive_after, Time | |
| # Assocations ::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| belongs_to :category |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]; |
NewerOlder