dkubb (owner)

Forks

Revisions

gist: 170779 Download_button fork
public
Description:
Base Model example
Public Clone URL: git://gist.github.com/170779.git
Embed All Files: show embed
base_model.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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