Skip to content

Conversation

@benjaminwood
Copy link
Contributor

Given that each command has a corresponding handle_* method, we don't really need a switch statement. We can just call the methods dynamically and rescue the NoMethodError. This makes it easier to handle new commands in the future by simply adding a new handle_* method.

I've also refactored how we break the main loop in the test scenario. Instead of returning true/false, a command can explicitly return :break.

Given that each command has a corresponding handle_ method, we don't
really need a switch statement. We can just call the methods dynamically
and rescue the NoMethodError. This makes it easier to handle new commands
in the future by simply adding a new handle_ method.

I've also refactored how we break the main loop in the test scenario.
Instead of returning true/false, a command can explicitly return :break.

Co-authored-by: Nate Vick <[email protected]>
@benjaminwood benjaminwood self-assigned this Dec 27, 2023
@benjaminwood benjaminwood mentioned this pull request Dec 27, 2023
Copy link
Contributor

@natevick natevick left a comment

Choose a reason for hiding this comment

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

Sweet!

@benjaminwood benjaminwood merged commit da8d683 into main Dec 28, 2023
@benjaminwood benjaminwood deleted the refactor-handle-command branch December 28, 2023 19:10
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