aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2012-04-29 16:04:10 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2012-04-29 16:04:10 -0700
commita89827e97c7e8887ca23e1279a481d548f63b262 (patch)
tree87b2ea6a2767103e0f2a66c6a2d5737c7f845911 /activesupport/lib/active_support
parent3de6a75d3fb06cc1da9251ed8ce1a11dd433d8cc (diff)
parent764f69e8418635d7aa6d42b750bf4d784580e895 (diff)
downloadrails-a89827e97c7e8887ca23e1279a481d548f63b262.tar.gz
rails-a89827e97c7e8887ca23e1279a481d548f63b262.tar.bz2
rails-a89827e97c7e8887ca23e1279a481d548f63b262.zip
Merge pull request #5999 from bogdan/callbacks
AS::Callbacks#run_callbacks optimized to reduce backtrace
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/callbacks.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 2a569d9a9b..cbeba3139a 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -76,7 +76,8 @@ module ActiveSupport
#
def run_callbacks(kind, key = nil, &block)
#TODO: deprecate key argument
- self.class.__run_callbacks(kind, self, &block)
+ runner_name = self.class.__define_callbacks(kind, self)
+ send(runner_name, &block)
end
private
@@ -323,18 +324,17 @@ module ActiveSupport
method << callbacks
method << "halted ? false : (block_given? ? value : true)"
- method.flatten.compact.join("\n")
+ method.join("\n")
end
end
module ClassMethods
- # This method runs callback chain for the given kind.
- # If this called first time it creates a new callback method for the kind.
+ # This method defines callback chain method for the given kind
+ # if it was not yet defined.
# This generated method plays caching role.
- #
- def __run_callbacks(kind, object, &blk) #:nodoc:
+ def __define_callbacks(kind, object) #:nodoc:
name = __callback_runner_name(kind)
unless object.respond_to?(name, true)
str = object.send("_#{kind}_callbacks").compile
@@ -343,7 +343,7 @@ module ActiveSupport
protected :#{name}
RUBY_EVAL
end
- object.send(name, &blk)
+ name
end
def __reset_runner(symbol)