57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/granite/form/model/dirty.rb', line 57
def define_dirty(method, target = self)
reflection = reflect_on_attribute(method)
name = reflection ? reflection.name : method
%w[changed? change will_change! was
previously_changed? previous_change].each do |suffix|
target.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{method}_#{suffix}
attribute_#{suffix} '#{name}'
end
RUBY
end
target.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def restore_#{method}!
restore_attribute! '#{name}'
end
RUBY
end
|