diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-08-21 00:51:06 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-21 00:51:06 -0500 |
commit | 6be8251ec86b74b92e7bd922fafe9224281d2d26 (patch) | |
tree | e8a87dd3524b3d80b381fc7dbb273a41c890dba2 /activesupport/lib/active_support | |
parent | f388725bd61d8ae246c0c8e42eaec1a2be4620ac (diff) | |
download | rails-6be8251ec86b74b92e7bd922fafe9224281d2d26.tar.gz rails-6be8251ec86b74b92e7bd922fafe9224281d2d26.tar.bz2 rails-6be8251ec86b74b92e7bd922fafe9224281d2d26.zip |
Simplified and renamed CallbackChain union method to replace_or_append!
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 9c59b7ac76..7b905930bb 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -96,15 +96,12 @@ module ActiveSupport end end - def |(chain) - if chain.is_a?(CallbackChain) - chain.each { |callback| self | callback } + # TODO: Decompose into more Array like behavior + def replace_or_append!(chain) + if index = index(chain) + self[index] = chain else - if (found_callback = find(chain)) && (index = index(chain)) - self[index] = chain - else - self << chain - end + self << chain end self end @@ -157,6 +154,14 @@ module ActiveSupport self.class.new(@kind, @method, @options.dup) end + def hash + if @identifier + @identifier.hash + else + @method.hash + end + end + def call(*args, &block) evaluate_method(method, *args, &block) if should_run_callback?(*args) rescue LocalJumpError |