lib/active_support/rescuable.rb in activesupport-3.0.pre vs lib/active_support/rescuable.rb in activesupport-3.0.0.rc

- old
+ new

@@ -1,15 +1,18 @@ -require 'active_support/core_ext/class/inheritable_attributes' +require 'active_support/concern' +require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/proc' +require 'active_support/core_ext/string/inflections' +require 'active_support/core_ext/array/extract_options' module ActiveSupport # Rescuable module adds support for easier exception handling. module Rescuable extend Concern included do - class_inheritable_accessor :rescue_handlers + class_attribute :rescue_handlers self.rescue_handlers = [] end module ClassMethods # Rescue exceptions raised in controller actions. @@ -63,11 +66,11 @@ else raise ArgumentError, "#{klass} is neither an Exception nor a String" end # put the new handler at the end because the list is read in reverse - rescue_handlers << [key, options[:with]] + self.rescue_handlers += [[key, options[:with]]] end end end # Tries to rescue the exception by looking up and calling a registered handler. @@ -79,10 +82,10 @@ end def handler_for_rescue(exception) # We go from right to left because pairs are pushed onto rescue_handlers # as rescue_from declarations are found. - _, rescuer = Array(rescue_handlers).reverse.detect do |klass_name, handler| + _, rescuer = self.class.rescue_handlers.reverse.detect do |klass_name, handler| # The purpose of allowing strings in rescue_from is to support the # declaration of handler associations for exception classes whose # definition is yet unknown. # # Since this loop needs the constants it would be inconsistent to