80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/active_data/model/attributes/base.rb', line 80
def pollute
pollute = owner.class.dirty? && !owner.send(:attribute_changed?, name)
if pollute
previous_value = owner.__send__(name)
owner.send("#{name}_will_change!")
result = yield
owner.__send__(:clear_attribute_changes, [name]) if owner.__send__(name) == previous_value
if previous_value != read || (
read.respond_to?(:changed?) &&
read.changed?
)
owner.send(:set_attribute_was, name, previous_value)
end
result
else
yield
end
end
|