procore-oss / blueprinter

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

[bug] A view key of nil is not using the default #471

Closed nickjer closed 1 month ago

nickjer commented 1 month ago

Is there an existing issue for this?

Is this a regression?

Current Behavior

Previously (in v1.1.0) the following worked...

MyBlueprint.render_as_json(my_object, view: nil)

Now (in v1.1.1) it raises with the exception...

#<Blueprinter::BlueprinterError: View '' is not defined>

I believe it was introduced when the following line was introduced:

https://github.com/procore-oss/blueprinter/blob/0e7f160d55e9f8cf53035f74af04bb33e6b739da/lib/blueprinter/helpers/base_helpers.rb#L18

Previously it was...

view_name = options.delete(:view) || :default

A possible solution is...

view_name = options[:view] || :default

Environment

- OS: Linux
- Browser Name and version: *
- Ruby Version: 3.3.4

Anything else?

No response

lessthanjacob commented 1 month ago

Thanks for opening the issue @nickjer! Was able to reproduce via test, and working on a quick fix!