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

Template: Don't assume mapping is enumerable #512

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Hbutlercapone
Copy link

this allows template expansions with lambdas or anything else that responds to []

levinalex and others added 2 commits July 30, 2013 13:25
this allows template expansions with lambdas or anything else
that responds to `[]`
@therabidbanana
Copy link
Collaborator

#133 (comment)

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?

@therabidbanana
Copy link
Collaborator

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"

main...therabidbanana:addressable:pr/133

Copy link
Collaborator

@therabidbanana therabidbanana left a 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)
Copy link
Collaborator

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)

Copy link
Author

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!

@Hbutlercapone
Copy link
Author

I will hop on after work tonight and take a look!

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.

None yet

3 participants