Skip to content
Browse files

Slight optimization to CallbackChain#union and delete.

  • Loading branch information...
1 parent 986aec5 commit a4c15303cbc96fffd66c68abdeebe73d8883e5ab @josh josh committed Apr 18, 2008
Showing with 5 additions and 6 deletions.
  1. +5 −6 activesupport/lib/active_support/callbacks.rb
View
11 activesupport/lib/active_support/callbacks.rb
@@ -97,15 +97,14 @@ def run(object, options = {}, &terminator)
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 @@ def find(callback, &block)
end
def delete(callback)
- super(find(callback))
+ super(callback.is_a?(Callback) ? callback : find(callback))
end
private

0 comments on commit a4c1530

Please sign in to comment.
Something went wrong with that request. Please try again.