10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ixtlan/models/domain.rb', line 10
def self.included(model)
model.send(:include, DataMapper::Resource)
model.property :id, ::DataMapper::Types::Serial
model.property :name, String, :required => true , :format => /^[a-z]+$|^#{ALL}$/, :length => 32, :unique_index => true
model.timestamps :created_at
model.modified_by Models::USER, :created_by
model.class_eval <<-EOS, __FILE__, __LINE__
def self.every
first(:name => ALL)
end
def self.first_or_get!(id_or_name)
first(:name => id_or_name) || get!(id_or_name)
end
def self.first_or_get(id_or_name)
first(:name => id_or_name) || get(id_or_name)
end
EOS
end
|