-
Notifications
You must be signed in to change notification settings - Fork 268
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
Template: Don't assume mapping is enumerable #512
base: main
Are you sure you want to change the base?
Conversation
this allows template expansions with lambdas or anything else that responds to `[]`
This point was made with an earlier request for this type of feature - I think we probably want to add some additional checks to make sure the API is solid and add a bit more to the docs? |
An additional commit that covers the requested doc updates, argument errors, and adds more tests for edge cases from this particular update (partial_expand doesn't make sense with a lambda). I can set up a new PR with the changes or you can cherry pick my commit into your PR @Hbutlercapone and clean them up some more if you'd like - I don't know how we'd want partial_expand to work here but there's a few ways we could approach it aside from "throw error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit with docs and some tests to cover the edge case with partial_expand - we should include that before merging
@@ -922,6 +922,7 @@ def normalize_value(value) | |||
# @return [Hash] | |||
# A hash with stringified keys | |||
def normalize_keys(mapping) | |||
return mapping unless mapping.respond_to?(:inject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I was adding more tests/docs for this I realized it's incomplete for #partial_expand
which requires something responding to #key?
because nil is a valid expansion value (which becomes an empty string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apoligize I did not mean to resolve it!
I will hop on after work tonight and take a look! |
this allows template expansions with lambdas or anything else that responds to
[]