blob: 26f83feb6b5c7c8da1a1635d193b43494f34a38f (
plain) (
blame)
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
|
module ActiveModel
module APICompliant
include Naming
def self.extended(klass)
klass.class_eval do
include Validations
include InstanceMethods
end
end
module InstanceMethods
def to_model
if respond_to?(:new_record?)
self.class.class_eval { def to_model() self end }
to_model
else
raise "In order to be ActiveModel API compliant, you need to define " \
"a new_record? method, which should return true if it has not " \
"yet been persisted."
end
end
end
end
end
|