Created
January 2, 2010 13:35
-
-
Save locks/267495 to your computer and use it in GitHub Desktop.
MongoDB experiments
This file contains 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
require 'rubygems' | |
require 'mongo_mapper' | |
class Subject | |
include MongoMapper::EmbeddedDocument | |
key :nome, String | |
key :ano, Integer | |
end | |
class Teacher | |
include MongoMapper::Document | |
connection Mongo::Connection.new('localhost') | |
set_database_name 'testing' | |
many :subjects | |
key :nome, String | |
key :idade, Integer | |
key :puta, Boolean | |
end | |
Teacher.new | |
lol = Teacher.new(:puta=>true, :idade=>92, :nome=>"Diogo Nuno") | |
lol.subjects << Subject.new(:nome=>"fornica", :ano=>2) | |
lol.subjects << Subject.new(:nome=>"chupar", :ano=>1) | |
puts lol.nome | |
puts "é puta? " + lol.puta.to_s | |
puts | |
puts "--disciplinas--" | |
lol.subjects.each do |subject| | |
puts subject.nome + " : " + subject.ano.to_s | |
end | |
puts "--/disciplinas--" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment