From 1caebf5d4f452f8a69402795dd31fadc38eddce5 Mon Sep 17 00:00:00 2001 From: Aaron Lasseigne Date: Fri, 22 Dec 2017 16:10:15 -0600 Subject: [PATCH] merge InvalidClassError and InvalidAncestorError into InvalidNameError --- CHANGELOG.md | 1 + lib/active_interaction/errors.rb | 9 ++------- lib/active_interaction/filters/interface_filter.rb | 2 +- lib/active_interaction/filters/object_filter.rb | 2 +- lib/active_interaction/filters/record_filter.rb | 2 +- spec/active_interaction/filters/interface_filter_spec.rb | 4 ++-- spec/active_interaction/filters/object_filter_spec.rb | 2 +- spec/active_interaction/filters/record_filter_spec.rb | 2 +- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d7f8f3f..b0b4fdd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ hash. The `ActiveInteraction::Input` still responds to all hash methods. - The `interface` filter will now look for an ancestor of the value passed based on the name of the interface or the value passed in the `from` option. +- The `InvalidClassError` has been replaced by `InvalidNameError`. ## Added diff --git a/lib/active_interaction/errors.rb b/lib/active_interaction/errors.rb index c78d6334..0fdecf2b 100644 --- a/lib/active_interaction/errors.rb +++ b/lib/active_interaction/errors.rb @@ -6,15 +6,10 @@ module ActiveInteraction # rubocop:disable Style/Documentation # @return [Class] Error = Class.new(StandardError) - # Raised if a class name is invalid. + # Raised if a constant name is invalid. # # @return [Class] - InvalidClassError = Class.new(Error) - - # Raised if an ancestor name is invalid. - # - # @return [Class] - InvalidAncestorError = Class.new(Error) + InvalidNameError = Class.new(Error) # Raised if a converter is invalid. # diff --git a/lib/active_interaction/filters/interface_filter.rb b/lib/active_interaction/filters/interface_filter.rb index 37b0d26c..5711c426 100644 --- a/lib/active_interaction/filters/interface_filter.rb +++ b/lib/active_interaction/filters/interface_filter.rb @@ -43,7 +43,7 @@ def from const_name = options.fetch(:from, name).to_s.camelize Object.const_get(const_name) rescue NameError - raise InvalidAncestorError, + raise InvalidNameError, "constant #{const_name.inspect} does not exist" end diff --git a/lib/active_interaction/filters/object_filter.rb b/lib/active_interaction/filters/object_filter.rb index debb3dd5..68e7ebf5 100644 --- a/lib/active_interaction/filters/object_filter.rb +++ b/lib/active_interaction/filters/object_filter.rb @@ -34,7 +34,7 @@ def klass klass_name = options.fetch(:class, name).to_s.camelize Object.const_get(klass_name) rescue NameError - raise InvalidClassError, "class #{klass_name.inspect} does not exist" + raise InvalidNameError, "class #{klass_name.inspect} does not exist" end def matches?(value) diff --git a/lib/active_interaction/filters/record_filter.rb b/lib/active_interaction/filters/record_filter.rb index 03233155..e934feaa 100644 --- a/lib/active_interaction/filters/record_filter.rb +++ b/lib/active_interaction/filters/record_filter.rb @@ -34,7 +34,7 @@ def klass klass_name = options.fetch(:class, name).to_s.camelize Object.const_get(klass_name) rescue NameError - raise InvalidClassError, "class #{klass_name.inspect} does not exist" + raise InvalidNameError, "class #{klass_name.inspect} does not exist" end def matches?(value) diff --git a/spec/active_interaction/filters/interface_filter_spec.rb b/spec/active_interaction/filters/interface_filter_spec.rb index 9873e818..b12cb8bb 100644 --- a/spec/active_interaction/filters/interface_filter_spec.rb +++ b/spec/active_interaction/filters/interface_filter_spec.rb @@ -166,7 +166,7 @@ class InterfaceClass; end it 'raises an error' do expect do result - end.to raise_error ActiveInteraction::InvalidAncestorError + end.to raise_error ActiveInteraction::InvalidNameError end end end @@ -323,7 +323,7 @@ class InterfaceClass; end it 'raises an error' do expect do result - end.to raise_error ActiveInteraction::InvalidAncestorError + end.to raise_error ActiveInteraction::InvalidNameError end end end diff --git a/spec/active_interaction/filters/object_filter_spec.rb b/spec/active_interaction/filters/object_filter_spec.rb index 7f7fbb2a..eac94750 100644 --- a/spec/active_interaction/filters/object_filter_spec.rb +++ b/spec/active_interaction/filters/object_filter_spec.rb @@ -132,7 +132,7 @@ class SubObjectThing < ObjectThing; end it 'raises an error' do expect do result - end.to raise_error ActiveInteraction::InvalidClassError + end.to raise_error ActiveInteraction::InvalidNameError end end diff --git a/spec/active_interaction/filters/record_filter_spec.rb b/spec/active_interaction/filters/record_filter_spec.rb index 7e7ca50a..887f7a6b 100644 --- a/spec/active_interaction/filters/record_filter_spec.rb +++ b/spec/active_interaction/filters/record_filter_spec.rb @@ -150,7 +150,7 @@ class SubRecordThing < RecordThing; end it 'raises an error' do expect do result - end.to raise_error ActiveInteraction::InvalidClassError + end.to raise_error ActiveInteraction::InvalidNameError end end