4
5
6
7
8
9
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/kaui/rails_methods.rb', line 4
def self.included(base_class)
base_class.class_eval do
extend ActiveModel::Naming
include ActiveModel::Validations
include ActiveModel::Conversion
def ==(other)
!other.nil? && self.class == other.class && self.to_hash == other.to_hash
end
def persisted?
false
end
def new_record?
!persisted?
end
def to_param
nil
end
def read_attribute_for_validation(attr)
send(attr)
end
def save
@errors.add(:save, 'Saving this object is not yet supported')
false
end
def update_attributes(tag_definition)
@errors.add(:update, 'Updating this object is not yet supported')
false
end
def destroy
@errors.add(:destroy, 'Destroying this object is not yet supported')
false
end
end
base_class.instance_eval do
def self.human_attribute_name(attr, options = {})
attr
end
def self.lookup_ancestors
[self]
end
def self.all
[]
end
def self.count
all.count
end
def self.find(id)
nil
end
end end
|