aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/callbacks.rb11
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