Created
November 6, 2011 07:14
-
-
Save jc00ke/1342585 to your computer and use it in GitHub Desktop.
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
# Imagine that Play & Author were stored in their own collections | |
# hanging off of Maglev.PERSISTENT_ROOT | |
class Play | |
attr_accessor :title | |
end | |
class Author | |
attr_accessor :name | |
def initialize | |
@plays = [] | |
end | |
def plays | |
@plays | |
end | |
def add_play(play) | |
@plays << play | |
end | |
end | |
Maglev.abort_transaction | |
bill = Author.new | |
bil.title = "William Shakespeare" | |
rnj = Play.new | |
rnj.title = "Romeo & Juliet" | |
bill.add_play(rnj) | |
Maglev.commit_transaction | |
Maglev.abort_transaction | |
assert("Romeo & Juliet", Author.first.plays.first.title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment