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
Safer argument parsing #220
Conversation
@@ -2,7 +2,8 @@ module Stripe | |||
module APIOperations | |||
module Create | |||
module ClassMethods | |||
def create(params={}, opts={}) |
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.
This change seems unnecessary. Tests pass without it.
@bobjflong Thanks for the pull request! I like the extra safety this provides. I left a few comments about changing the approach a bit; other than that I'll be happy to merge this. |
thanks @russelldavis made a bunch of changes based on your feedback |
@@ -119,21 +119,35 @@ def self.flatten_params_array(value, calculated_key) | |||
def self.parse_opts(opts) | |||
case opts | |||
when NilClass |
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.
What do you think about just getting rid of this when NilClass
clause altogether and letting the else
clause handle it? (In which case you could also merge raise_bad_api_key
into check_bad_api_key
, since that would be the only place it's used.)
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.
Great catch, fixed
Github says there are conflicts that need to be resolved -- can you rebase against master and resolve those? |
Huh weird. Will do tomorrow |
Ugh seems like my local files were super out of date. Going to replay my changes in a new pr. |
An issue I've seen crop up is that if a global key is set (which most of your docs use), and then client API keys are used (eg. if using OAuth), then unexpected results can happen. This includes loading customer data from the parent global key.
With my changes: