Skip to content

Add Hash-splat operator to GithubHelper methods#424

Merged
AliSoftware merged 3 commits intowordpress-mobile:trunkfrom
raafaelima:add/hash-splat-operator-to-githubhelper
Nov 3, 2022
Merged

Add Hash-splat operator to GithubHelper methods#424
AliSoftware merged 3 commits intowordpress-mobile:trunkfrom
raafaelima:add/hash-splat-operator-to-githubhelper

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