83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/no_brainer/document/dirty.rb', line 83
def field(attr, options={})
super
attr = attr.to_s
inject_in_layer :dirty_tracking do
define_method("#{attr}_change") do
if @_old_attributes.key?(attr)
result = [@_old_attributes[attr], _read_attribute(attr)]
result if result.first != result.last || !@_old_attributes_keys.include?(attr)
end
end
define_method("#{attr}_changed?") do
!!__send__("#{attr}_change")
end
define_method("#{attr}_was") do
@_old_attributes.key?(attr) ? @_old_attributes[attr] : _read_attribute(attr)
end
end
end
|