vendor/activesupport/lib/active_support/callbacks.rb in relevance-castronaut-0.5.4 vs vendor/activesupport/lib/active_support/callbacks.rb in relevance-castronaut-0.6.0

- old
+ new

@@ -94,19 +94,16 @@ break result if terminator.call(result, object) end 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 def find(callback, &block) @@ -155,10 +152,18 @@ def dup 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 raise ArgumentError, "Cannot yield from a Proc type filter. The Proc must take two " + @@ -181,10 +186,10 @@ else raise ArgumentError, "Callbacks must be a symbol denoting the method to call, a string to be evaluated, " + "a block to be invoked, or an object responding to the callback method." end - end + end end def should_run_callback?(*args) if options[:if] evaluate_method(options[:if], *args)