Skip to content

Commit

Permalink
merge InvalidClassError and InvalidAncestorError into InvalidNameError
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronLasseigne committed Jan 10, 2021
1 parent 3361f01 commit 1caebf5
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 2 additions & 7 deletions lib/active_interaction/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/active_interaction/filters/interface_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/active_interaction/filters/object_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_interaction/filters/record_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions spec/active_interaction/filters/interface_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/active_interaction/filters/object_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/active_interaction/filters/record_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1caebf5

Please sign in to comment.