Created
January 10, 2009 16:28
-
-
Save ravinggenius/45488 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
include 'dm-is-list' | |
class Node | |
include DataMapper::Resource | |
property :id, Serial | |
# other properties... | |
has n, :parts | |
end | |
# Part is abstract, but should create a 'header' table | |
class Part | |
include DataMapper::Resource | |
property :id, Serial | |
# multi-table inheritence | |
# there should be fields for the derived class name and its id | |
#property :type, Discriminator # ?? | |
property :subtitle, String, :nullable => false | |
belongs_to :node | |
is :list | |
end | |
class PartText < Part | |
include DataMapper::Resource | |
property :id, Serial | |
property :data, Text, :nullable => false | |
end | |
class PartTable < Part | |
include DataMapper::Resource | |
property :id, Serial | |
property :caption, String | |
property :cells, Csv, :nullable => false | |
# other properties | |
end | |
# Desired Usage | |
# | |
# table = PartTable.new | |
# table.caption = '...' | |
# table.cells = 'Some,csv' | |
# | |
# text = PartText.new | |
# text.data = 'Really long passage of text' | |
# | |
# node = Node.new | |
# node.parts << table | |
# node.parts << text | |
# node.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment