Created
July 15, 2010 02:48
-
-
Save levicole/476429 to your computer and use it in GitHub Desktop.
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
| # so this is super sexy | |
| require 'rubygems' | |
| require 'mongo_doc' | |
| require 'mustache' | |
| class Person < Mustache | |
| attr_accessor :name, :age, :interests | |
| def pretty_interests | |
| last = interests.pop | |
| "#{interests.join(", ")} and #{last}" | |
| end | |
| end | |
| collection = MongoDoc::Collection.new('people') | |
| collection.drop | |
| person = Person.new | |
| person.name = "Levi Cole" | |
| person.age = "26" | |
| person.interests = ["ruby", "hipster girls", "guitars", "bluegrass"] | |
| collection.save(person) | |
| levis = collection.where('name' => /Levi/) | |
| template = "Hello, may name is {{name}}, I am {{age}}, and I like {{pretty_interests}}" | |
| puts levis.first.render(template) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment