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

Use Forwardable within Message to avoid method boilerplate #681

Conversation

GabrielMalakias
Copy link
Contributor

First of all, thank you for maintaining this gem! I really appreciate your efforts.

While diving into the code I just noticed that a bunch of methods were defined just as a proxy to the data structure.

As I have seen here: https://github.com/ruby-shoryuken/shoryuken/blob/master/lib/shoryuken.rb#L48 I decided to use the SingleForwardable to delegate to the structure directly.

It's a small thing for now but might the beginning of some contributions

@cjlarose
Copy link
Collaborator

Thanks for your contribution! Tests are failing. I think you might want to look into Forwardable instead of SingleForwardable.

https://ruby-doc.org/stdlib-2.6.2/libdoc/forwardable/rdoc/Forwardable.html

@GabrielMalakias GabrielMalakias changed the title Use SingleForwardable within Message to avoid method boilerplate Use Forwardable within Message to avoid method boilerplate Oct 19, 2021
@GabrielMalakias
Copy link
Contributor Author

Done

@cjlarose
Copy link
Collaborator

Awesome work! Thanks!

@cjlarose cjlarose merged commit 142930a into ruby-shoryuken:master Oct 25, 2021
:attributes,
:md5_of_message_attributes,
:message_attributes)

Copy link

Choose a reason for hiding this comment

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

A minor thing but skipping the parentheses in this case would match the macro-style methods better and also sorting the lines ascending would make it easier to read, e.g.:

def_delegators :attributes,
               :body,
               :data,
               :md5_of_body,
               :md5_of_message_attributes,
               :message_attributes,
               :message_id,
               :receipt_handle

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.

3 participants