stas / jsonapi.rb

Lightweight, simple and maintained JSON:API support for your next Ruby HTTP API.
MIT License
261 stars 57 forks source link

Use is_a?(Enumerable) instead of respond_to?(:size) to detect collections #76

Closed dmolesUC closed 2 years ago

dmolesUC commented 2 years ago

What is the current behavior?

Non-collection objects with size attribute are mistakenly treated as collections, causing serialization to fail (see #75).

What is the new behavior?

Only Enumerables are treated as collections, cf. the corresponding method in jsonapi-serializer.

Fixes #75.

Checklist

Please make sure the following requirements are complete:

Notes

It looks like the build may be currently failing for other reasons?

stas commented 2 years ago

@dmolesUC any reason we don't want to switch to directly call JSONAPI::Serializer.is_collection? ?

stas commented 2 years ago

Ah, nvm, just saw you answered in the issue. I'll merge this and fix the CI. Sorry about that.

dmolesUC commented 2 years ago

@stas It looks like the build is failing due to an unrelated RuboCop failure. Oops, never mind — I see you saw that.