diff options
author | Genadi Samokovarov <gsamokovarov@gmail.com> | 2018-12-29 17:27:33 +0200 |
---|---|---|
committer | Genadi Samokovarov <gsamokovarov@gmail.com> | 2019-04-19 14:15:22 +0900 |
commit | a3110fe20bc418034332bd01165df7fe6f20258e (patch) | |
tree | 2bbddbe477f6078d1d75f9614c40953dc4ad09a6 /activesupport/lib | |
parent | 54df392bc51dcf424f07ccc10157a5969256ba73 (diff) | |
download | rails-a3110fe20bc418034332bd01165df7fe6f20258e.tar.gz rails-a3110fe20bc418034332bd01165df7fe6f20258e.tar.bz2 rails-a3110fe20bc418034332bd01165df7fe6f20258e.zip |
Drop the ambiguous `ActiveSupport::ActionableError#===` check
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/actionable_error.rb | 23 |
1 files changed, 14 insertions, 9 deletions
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: |