procore-oss / blueprinter

Simple, Fast, and Declarative Serialization Library for Ruby
MIT License
1.14k stars 109 forks source link

Check if an array_like object is an Enumerable #302

Closed triciatzy closed 1 year ago

triciatzy commented 1 year ago

Context

When passing an array like ActiveModel::Errors, I'm unable to render blueprint because it does not pass array_like? condition. Both [] and ActiveModel::Errors are Enumerable, I'm proposing to check if array is Enumerable instead.

Let me know what you guys think? Thank you.

Usage Example

Before

ModelBlueprint.render(model.errors.full_messages, root: :errors)

After

ModelBlueprint.render(model.errors, root: :errors)
ritikesh commented 1 year ago

@triciatzy - we recently fixed this in the fork - https://github.com/blueprinter-ruby/blueprinter/pull/6. Pls let me know if it helps.

triciatzy commented 1 year ago

Thanks @ritikesh