Skip to content

Commit

Permalink
Move rescue_from type from an interface to ActiveSupport::Rescuable…
Browse files Browse the repository at this point in the history
…::ClassMethods (ruby#462)

* actionpack: Do not redefine ActionController::Base.rescue_from

`.rescue_from` method is defined in `ActiveSupport::Rescuable::ClassMethods`. Therefore
it would be better to extend it instead of redefinition.

* Move rescue_from type definition from an interface to a class

---------

Co-authored-by: Takeshi KOMIYA <[email protected]>
  • Loading branch information
2 people authored and sw-square committed Jan 22, 2024
1 parent bd59d6a commit 0e7a1ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 4 additions & 7 deletions gems/actionpack/6.0/actioncontroller.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ module ActionController
def flash: () -> untyped
end

interface _API_and_Base_singletion
def rescue_from: (*Class, ?with: Symbol | Proc) -> void
| (*Class) { (Exception) -> void } -> void
end

class Base < Metal
include _API_and_Base
extend _API_and_Base_singletion

# https://github.com/rails/rails/blob/v6.0.3.2/actionpack/lib/action_controller/base.rb#L205-L255
include AbstractController::Rendering
Expand Down Expand Up @@ -59,6 +53,8 @@ module ActionController
include AbstractController::Callbacks
extend AbstractController::Callbacks::ClassMethods
include Rescue
include ActiveSupport::Rescuable
extend ActiveSupport::Rescuable::ClassMethods
include Instrumentation
extend Instrumentation::ClassMethods
include ParamsWrapper
Expand All @@ -67,7 +63,6 @@ module ActionController

class API < Metal
include _API_and_Base
extend _API_and_Base_singletion

# https://github.com/rails/rails/blob/v6.0.3.2/actionpack/lib/action_controller/api.rb#L112-L145
include AbstractController::Rendering
Expand All @@ -87,6 +82,8 @@ module ActionController
include AbstractController::Callbacks
extend AbstractController::Callbacks::ClassMethods
include Rescue
include ActiveSupport::Rescuable
extend ActiveSupport::Rescuable::ClassMethods
include Instrumentation
extend Instrumentation::ClassMethods
include ParamsWrapper
Expand Down
3 changes: 2 additions & 1 deletion gems/activesupport/6.0/activesupport-generated.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -10819,7 +10819,8 @@ module ActiveSupport
# end
#
# Exceptions raised inside exception handlers are not propagated up.
def rescue_from: (*untyped klasses, ?with: untyped? with) { () -> untyped } -> untyped
def rescue_from: (*Class, ?with: Symbol | Proc) -> void
| (*Class) { (Exception) -> void } -> void

# Matches an exception to a handler based on the exception class.
#
Expand Down

0 comments on commit 0e7a1ef

Please sign in to comment.