提交 73ee85f3 编写于 作者: A Aaron Patterson

push methods that don't depend on the instance to the class

上级 07d522b1
......@@ -14,8 +14,8 @@ def self.valid_dependent_options
def define_callbacks(model, reflection)
super
add_counter_cache_callbacks(model, reflection) if reflection.options[:counter_cache]
add_touch_callbacks(model, reflection) if reflection.options[:touch]
self.class.add_counter_cache_callbacks(model, reflection) if reflection.options[:counter_cache]
self.class.add_touch_callbacks(model, reflection) if reflection.options[:touch]
end
def define_accessors(mixin, reflection)
......@@ -70,7 +70,7 @@ def belongs_to_counter_cache_after_update(reflection)
end
end
def add_counter_cache_callbacks(model, reflection)
def self.add_counter_cache_callbacks(model, reflection)
cache_column = reflection.counter_cache_column
model.after_create lambda { |record|
......@@ -115,7 +115,7 @@ def self.touch_record(o, foreign_key, name, touch) # :nodoc:
end
end
def add_touch_callbacks(model, reflection)
def self.add_touch_callbacks(model, reflection)
foreign_key = reflection.foreign_key
n = reflection.name
touch = reflection.options[:touch]
......
......@@ -28,7 +28,7 @@ def define_callbacks(model, reflection)
name = reflection.name
options = reflection.options
CALLBACKS.each { |callback_name|
define_callback(model, callback_name, name, options)
self.class.define_callback(model, callback_name, name, options)
}
end
......@@ -39,7 +39,7 @@ def define_extensions(model)
end
end
def define_callback(model, callback_name, name, options)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册