Skip to content

Commit 2c853dd

Browse files
authored
Ensure eql? comparison object is the type expected (#1368)
1 parent 49d213d commit 2c853dd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/jsonapi/path_segment.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize(relationship:, resource_klass: nil)
3030
end
3131

3232
def eql?(other)
33-
relationship == other.relationship && resource_klass == other.resource_klass
33+
other.is_a?(JSONAPI::PathSegment::Relationship) && relationship == other.relationship && resource_klass == other.resource_klass
3434
end
3535

3636
def hash
@@ -59,7 +59,7 @@ def initialize(resource_klass:, field_name:)
5959
end
6060

6161
def eql?(other)
62-
field_name == other.field_name && resource_klass == other.resource_klass
62+
other.is_a?(JSONAPI::PathSegment::Field) && field_name == other.field_name && resource_klass == other.resource_klass
6363
end
6464

6565
def delegated_field_name

0 commit comments

Comments
 (0)