Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Kernel#Array to cast values to an Array #197

Merged
merged 1 commit into from
Aug 13, 2021
Merged

Conversation

no-reply
Copy link

squash out error prone local logic for array casting, use Kernel#Array
instead.

the older logic would fail to cast in the case that the value was a String,
requiring a tight integration between the forms input objects and the
application's forms/models. since the very next line is going to fail if we fail
to cast to an Array, let's do so aggressively here.

it looks as though this line once used Array#wrap for this, but this only
works if the object responds to #to_ary (Ruby's implicit cast); otherwise
it results in a value like [["blah"]]. Kernel#Array is willing to perform an
explicit cast.

squash out error prone local logic for array casting, use `Kernel#Array`
instead.

the older logic would fail to cast in the case that the value was a String,
requiring a tight integration between the forms input objects and the
application's forms/models. since the very next line is going to fail if we fail
to cast to an Array, let's do so aggressively here.

it looks as though this line once used `Array#wrap` for this, but this only
works if the object responds to `#to_ary` (Ruby's implicit cast); otherwise
it results in a value like `[["blah"]]`. `Kernel#Array` is willing to perform an
explicit cast.
@jrgriffiniii jrgriffiniii merged commit 478596e into main Aug 13, 2021
@jrgriffiniii jrgriffiniii deleted the simplify-array-wrap branch August 13, 2021 16:04
no-reply pushed a commit to samvera/hyrax that referenced this pull request Aug 13, 2021
no-reply pushed a commit to samvera/hyrax that referenced this pull request Aug 13, 2021
no-reply pushed a commit to samvera/hyrax that referenced this pull request Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants