From a3110fe20bc418034332bd01165df7fe6f20258e Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Sat, 29 Dec 2018 17:27:33 +0200 Subject: Drop the ambiguous `ActiveSupport::ActionableError#===` check --- .../lib/active_support/actionable_error.rb | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/actionable_error.rb b/activesupport/lib/active_support/actionable_error.rb index aeee2177aa..be4972759b 100644 --- a/activesupport/lib/active_support/actionable_error.rb +++ b/activesupport/lib/active_support/actionable_error.rb @@ -15,20 +15,25 @@ module ActiveSupport NonActionable = Class.new(StandardError) - included do - class_attribute :_actions, default: Hash.new do |_, label| - raise NonActionable, "Cannot find action \"#{label}\" for #{self}" - end + NoActions = Hash.new do |_, label| # :nodoc: + raise NonActionable, "Cannot find action \"#{label}\" for #{self}" end - def self.===(other) # :nodoc: - super || Module === other && other.ancestors.include?(self) + included do + class_attribute :_actions, default: NoActions.dup end def self.actions(error) # :nodoc: - error = error.constantize if String === error - raise NonActionable, "#{error.name} is non-actionable" unless self === error - error._actions + case error + when String + actions(error.constantize) + when ActionableError, -> it { Class === it && it < ActionableError } + error._actions + when Exception + NoActions + else + raise NonActionable, "#{error} is non-actionable" + end end def self.dispatch(error, label) # :nodoc: -- cgit v1.2.3