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

Clone non-frozen default params with each use (#1438) #1439

Closed
wants to merge 1 commit into from

Conversation

jlfaber
Copy link
Contributor

@jlfaber jlfaber commented Jul 14, 2016

No description provided.

@jlfaber jlfaber force-pushed the bug_#1438 branch 2 times, most recently from d72edad to 706713c Compare July 14, 2016 17:19
@jlfaber
Copy link
Contributor Author

jlfaber commented Jul 14, 2016

This should address #1438 .

Right now, it appears to be failing because of #1440. Once that fix merges, I'll rebase to pick it up and re-run the CI build.

@jlfaber
Copy link
Contributor Author

jlfaber commented Jul 17, 2016

Rebased. All tests now passing, so this is ready for review. @dblock

@@ -12,6 +12,7 @@

#### Fixes

* [#1438](/~https://github.com/ruby-grape/grape/pull/1439): Fix for default param modification bug - [@jlfaber](/~https://github.com/jlfaber).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets write something more useful, maybe "Default values in params are now cloned on assignment"?

@jlfaber
Copy link
Contributor Author

jlfaber commented Jul 19, 2016

@dblock, I've updated the PR:

  • simplify validate! by refactoring
  • reword CHANGELOG message
  • use dup instead of clone
  • use frozen default values as-is, without duping, since they're not subject to the bug. (See line notes for more on this).

This should be ready to go if you concur with the changes.

@@ -6,8 +6,30 @@ def initialize(attrs, options, required, scope)
super
end

# return true if we know we cannot dup this object
private def cannot_dup(obj)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ....?, but I would write this as the other way around, so maybe duplicatable?, which is how ActiveRecord calls these things I believe.

@dblock
Copy link
Member

dblock commented Jul 19, 2016

This is good. I have nitpicks on naming, otherwise it's ready to go.

@jlfaber
Copy link
Contributor Author

jlfaber commented Jul 19, 2016

Renamed and reformatted as requested by @dblock .

@dblock
Copy link
Member

dblock commented Jul 20, 2016

Merged via 8b72144, cc: @ashkan18 check it out.

@dblock dblock closed this Jul 20, 2016
@jlfaber jlfaber deleted the bug_#1438 branch July 20, 2016 13:40
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