mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
push methods that don't depend on the instance to the class
This commit is contained in:
parent
07d522b1be
commit
73ee85f39d
2 changed files with 6 additions and 6 deletions
|
@ -14,8 +14,8 @@ module ActiveRecord::Associations::Builder
|
|||
|
||||
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 @@ module ActiveRecord::Associations::Builder
|
|||
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 @@ module ActiveRecord::Associations::Builder
|
|||
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 @@ module ActiveRecord::Associations::Builder
|
|||
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 @@ module ActiveRecord::Associations::Builder
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue