diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-04-18 14:44:55 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-04-18 14:44:55 -0500 |
commit | a4c15303cbc96fffd66c68abdeebe73d8883e5ab (patch) | |
tree | a4f340a421706bdf5f001700fb6cfed850d7ad0c | |
parent | 986aec5dbbdfb578945e706cbe6a54c4f06640e5 (diff) | |
download | rails-a4c15303cbc96fffd66c68abdeebe73d8883e5ab.tar.gz rails-a4c15303cbc96fffd66c68abdeebe73d8883e5ab.tar.bz2 rails-a4c15303cbc96fffd66c68abdeebe73d8883e5ab.zip |
Slight optimization to CallbackChain#union and delete.
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 282b6cbcbc..5c51237049 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -97,15 +97,14 @@ module ActiveSupport end def |(chain) - if chain.is_a?(Callback) - if found_callback = find(chain) - index = index(found_callback) + if chain.is_a?(CallbackChain) + chain.each { |callback| self | callback } + elsif chain.is_a?(Callback) + if index = index(chain) self[index] = chain else self << chain end - else - chain.each { |callback| self | callback } end self end @@ -115,7 +114,7 @@ module ActiveSupport end def delete(callback) - super(find(callback)) + super(callback.is_a?(Callback) ? callback : find(callback)) end private |