Stop generating unnecessary methods for association callbacks

The instance and predicate methods are used by Rails so there is no need
to generate them.
上级 3803671a
......@@ -30,8 +30,10 @@ def self.define_extensions(model, name, &block)
def self.define_callback(model, callback_name, name, options)
full_callback_name = "#{callback_name}_for_#{name}"
# TODO : why do i need method_defined? I think its because of the inheritance chain
model.class_attribute full_callback_name unless model.method_defined?(full_callback_name)
unless model.method_defined?(full_callback_name)
model.class_attribute(full_callback_name, instance_accessor: false, instance_predicate: false)
end
callbacks = Array(options[callback_name.to_sym]).map do |callback|
case callback
when Symbol
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册