147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/dolzenko/django_f_object.rb', line 147
def define_method_attribute_with_f_object=(attr_name)
send(:define_method_attribute_without_f_object=, attr_name)
method_body, line = <<-EOV, __LINE__ + 1
def #{attr_name}_with_f_object=(time)
if time.is_a?(F)
time.klass = self.class
write_attribute(:#{attr_name}, time)
else
send(:#{attr_name}_without_f_object=, time)
end
end
alias_method_chain_once :#{attr_name}=, :f_object unless respond_to?(:#{attr_name}_without_f_object=)
EOV
generated_attribute_methods.module_eval(method_body, __FILE__, line)
end
|