Created
August 20, 2009 02:31
-
-
Save dkubb/170779 to your computer and use it in GitHub Desktop.
Base Model example
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
module BaseModel | |
def self.included(model) | |
model.class_eval <<-RUBY, __FILE__, __LINE__ + 1 | |
include DataMapper::Resource | |
property :id, Serial | |
timestamps :at | |
RUBY | |
end | |
end | |
class Customer | |
include BaseModel | |
property :name, String | |
has n, :orders | |
end | |
class Order | |
include BaseModel | |
property :reference_code, String | |
belongs_to :customer | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment