Skip to content

Commit

Permalink
push methods that don't depend on the instance to the class
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 2, 2013
1 parent 07d522b commit 73ee85f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -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)
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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]
Expand Down
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 73ee85f

Please sign in to comment.