Created
October 12, 2010 10:59
-
-
Save solnic/622002 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
| #!/usr/bin/env ruby | |
| # | |
| # encoding: utf-8 | |
| require 'dm-sqlite-adapter' | |
| require 'dm-migrations' | |
| require 'dm-validations' | |
| DataMapper.setup :default, "sqlite::memory:" | |
| module App | |
| class File | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :type, Discriminator | |
| property :name, String | |
| belongs_to :folder, :required => false | |
| end | |
| class Folder < File | |
| has n, :files | |
| end | |
| end | |
| DataMapper.finalize | |
| DataMapper.auto_migrate! | |
| file = App::File.new(:name => "foo.txt") | |
| folder = App::Folder.create(:name => "Docs", :files => [file]) | |
| puts folder.files.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment