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

Added ActionController::Parameters.each_value methods #33979

Merged
merged 1 commit into from Sep 27, 2018

Conversation

@lzap
Copy link
Contributor

@lzap lzap commented Sep 25, 2018

Although Parameters class is far from implementing Hash and it's obvious that
it's not primarly goal to achieve it, having the two convinient methods for
iterating through parameters makes it more quacking like Hash:

  • each_value
  • each_key
@rails-bot
Copy link

@rails-bot rails-bot commented Sep 25, 2018

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.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@@ -77,7 +77,6 @@ def path_parameters=(parameters) #:nodoc:
end

# Returns a hash with the \parameters used to form the \path of the request.
# Returned hash keys are strings:
Copy link
Contributor Author

@lzap lzap Sep 25, 2018

I see a left over. To be removed.

Copy link
Member

@eileencodes eileencodes Sep 25, 2018

I'm confused. Do you mean you need to add this back or this was left over in a previous PR? It looks like from the example below that the keys are strings.

Copy link
Contributor Author

@lzap lzap Sep 27, 2018

Sorry I mean, I am going to remove this hunk in the next rebase. Let's do this.

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Sep 25, 2018

We don't want to make Parameters support all Hash values. I'm fine with each keys but each values will skip the parameters protection that we want to enforce. If you want to use those method please transform the parameters in hash using to_h.

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Sep 25, 2018

Although we already have to_pair. Let's add those methods but delegate each_pair and each_value to to_h. If you are calling those methods in a un-permitted Parameter instance we should raise.

@rafaelfranca rafaelfranca reopened this Sep 25, 2018
@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Sep 25, 2018

Forget about that, changing behaviour of each to yield hashes will be a breaking change. each_key is already supported. Let's change this PR to only implement each_value.

@lzap
Copy link
Contributor Author

@lzap lzap commented Sep 27, 2018

Rebased: new implementation of only each_value, tests for both each_value and each_key. For the latter I am asserting String type, not sure what else I can assert.

@lzap lzap changed the title Added ActionController::Parameters.each_value/key methods Added ActionController::Parameters.each_value methods Sep 27, 2018
@rafaelfranca rafaelfranca merged commit 140ec68 into rails:master Sep 27, 2018
1 of 2 checks passed
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this issue Oct 14, 2018
`each_value` should yield with value instead of an array.
Related to rails#33979
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this issue Oct 14, 2018
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this issue Oct 14, 2018
`each_value` should yield with "value" of the params instead of "value" as an array.
Related to rails#33979
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this issue Oct 14, 2018
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this issue Oct 15, 2018
`each_value` should yield with "value" of the params instead of "value" as an array.
Related to rails#33979
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this issue Oct 15, 2018
kamipo added a commit that referenced this issue Oct 15, 2018
… to this method (#34210)

* Fix `ActionController::Parameters#each_value`

`each_value` should yield with "value" of the params instead of "value" as an array.
Related to #33979

* Add changelog entry about `ActionController::Parameters#each_value`.

Follow up #33979
suketa added a commit to suketa/rails_sandbox that referenced this issue Jun 9, 2019
Added ActionController::Parameters.each_value methods
rails/rails#33979
suketa added a commit to suketa/rails_sandbox that referenced this issue Jun 9, 2019
Added ActionController::Parameters.each_value methods
rails/rails#33979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants