Skip to content

Commit

Permalink
callback chain is in charge of the cache, so remove method based cache
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 10, 2013
1 parent a3e9d6b commit c5ed42a
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions activesupport/lib/active_support/callbacks.rb
Expand Up @@ -427,23 +427,6 @@ def remove_duplicates(callback)

module ClassMethods

def __reset_runner(symbol)
name = __callback_runner_name(symbol)
undef_method(name) if method_defined?(name)
end

def __callback_runner_name_cache
@__callback_runner_name_cache ||= ThreadSafe::Cache.new {|cache, kind| cache[kind] = __generate_callback_runner_name(kind) }
end

def __generate_callback_runner_name(kind)
"_run__#{self.name.hash.abs}__#{kind}__callbacks"
end

def __callback_runner_name(kind)
__callback_runner_name_cache[kind]
end

# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
def __update_callbacks(name, filters = [], block = nil) #:nodoc:
Expand All @@ -454,7 +437,6 @@ def __update_callbacks(name, filters = [], block = nil) #:nodoc:
([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse.each do |target|
chain = target.send("_#{name}_callbacks")
yield target, chain.dup, type, filters, options
target.__reset_runner(name)
end
end

Expand Down Expand Up @@ -539,12 +521,9 @@ def reset_callbacks(symbol)
chain = target.send("_#{symbol}_callbacks").dup
callbacks.each { |c| chain.delete(c) }
target.send("_#{symbol}_callbacks=", chain)
target.__reset_runner(symbol)
end

self.send("_#{symbol}_callbacks=", callbacks.dup.clear)

__reset_runner(symbol)
end

# Define sets of events in the object lifecycle that support callbacks.
Expand Down

0 comments on commit c5ed42a

Please sign in to comment.