Skip to content

Instantly share code, notes, and snippets.

@dkubb
Created August 20, 2009 02:31
Show Gist options
  • Save dkubb/170779 to your computer and use it in GitHub Desktop.
Save dkubb/170779 to your computer and use it in GitHub Desktop.
Base Model example
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