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

Return a sized Enumerator from Hash#transform_values{!} #21806

Merged
merged 1 commit into from Nov 7, 2015

Conversation

Projects
None yet
4 participants
@kachick
Contributor

kachick commented Sep 29, 2015

No description provided.

@rails-bot

This comment has been minimized.

rails-bot commented Sep 29, 2015

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @eileencodes (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@kachick kachick force-pushed the kachick:fix-transformer-size branch from 3692a2c to 42eb3c6 Sep 29, 2015

@@ -21,12 +21,14 @@ class TransformKeysTest < ActiveSupport::TestCase
test "transform_keys returns an Enumerator if no block is given" do
original = { a: 'a', b: 'b' }
enumerator = original.transform_keys
assert_nil enumerator.size

This comment has been minimized.

@matthewd

matthewd Sep 29, 2015

Member

Can't we teach transform_keys to do this too?

This comment has been minimized.

@kachick

kachick Sep 29, 2015

Contributor

For below case. I believe transform_keys{!} can't settlement own size 😃

origin = {a: 1, A: 2}
origin.transform_keys(&:downcase) #=> {:a=>2}

This comment has been minimized.

@matthewd

matthewd Sep 29, 2015

Member

I think Enumerator#size is the number of times it'll yield, not the size of whatever might get returned. So, origin.transform_keys.size #=> 2.

This comment has been minimized.

@kachick

kachick Sep 29, 2015

Contributor

Oops... You're right! I'll update this patch.

@kachick kachick force-pushed the kachick:fix-transformer-size branch from 42eb3c6 to 8685c3e Sep 29, 2015

@kachick kachick force-pushed the kachick:fix-transformer-size branch from 8685c3e to 9addcbb Sep 29, 2015

eileencodes added a commit that referenced this pull request Nov 7, 2015

Merge pull request #21806 from kachick/fix-transformer-size
Return a sized Enumerator from Hash#transform_values{!}

@eileencodes eileencodes merged commit 24bddfc into rails:master Nov 7, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kachick

This comment has been minimized.

Contributor

kachick commented Nov 7, 2015

🙇

@kachick kachick deleted the kachick:fix-transformer-size branch Nov 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment