-
Notifications
You must be signed in to change notification settings - Fork 44
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
Simplify headers handling #295
Conversation
This improvement creates a new attr to be instantiated during the initializer and after the instantiation it could not be updated directly, just copies of it. The general idea was to remove some helper methods `clone_options` and `merge_options` that only had a purpouse because we have been handling the headers inside a hash (options hash). This extra complexity makes the requirement to have all these internal structures in order to be possible to add/remove and modify the items inside of it. After this we should only update a clone when it's required like was did in the lines 30, 41, 72.
* Avoid parameter lists longer than 5 parameters. [6/5]
def build_default_options_headers | ||
{ | ||
'Content-Type' => 'application/json', | ||
'Authorization' => ("Bearer #{@api_key}" unless @api_key.nil?) |
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.
That I was trying to show to you @curquiza that day #273 comment 😅
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.
Sooooooo cool!
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.
👌
Thanks brubru!!
bors merge |
This improvement creates a new attr to be instantiated during the initializer phase and after the instantiation, it could not be updated directly, just copies of it using
dup
.This should simplify the headers handling since they were mixed with options.
Originally extracted from #292