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

Add Hash-splat operator to GithubHelper methods #424

Conversation

raafaelima
Copy link
Contributor

What does this solve?

As discussed here at PR #420. This PR aims to add the hash conversion operator (aka **) to the methods on GithubHelper that use the named param options: in their signature. With this, we hope to improve the legibility and make those methods calls cleaner.

Good, but what is this Hash Operator?

This operator will allow the call site of those methods to just provide the options: variable/parameter directly as if they were keywords (kinda "flattening the Hash into keyword parameters") without having to wrap those options into { … } curly braces to make them a Hash. So the call site would look like this:

Instead of

github_helper.update_milestone(repository: repository, number: milestone[:number], options: { title: mile_title })

We'd have:

# Inside `update_milestone`'s implementation, the variable/parameter `options` would be a Hash equal to `{ title: mile_title }`
github_helper.update_milestone(repository: repository, number: milestone[:number], title: mile_title)

The change was done to make the method signature cleaner to call
The change was done to make the method signature cleaner to use the options parameter as named parameters
The change was done to make the method signature cleaner to use the options parameter as named parameters
@AliSoftware AliSoftware self-requested a review November 3, 2022 15:23
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Nice 👍
:shipit:

@AliSoftware AliSoftware merged commit 15c5b99 into wordpress-mobile:trunk Nov 3, 2022
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