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

Adds support for ruby 3.0 pattern matching #200

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bonflintstone
Copy link

This is simply done by implementing deconstruct_keys in the context, and will enable one to use interactors like this:

context = MyInteractor.()

case context
in success: true, result: { first:, second: }
  do_stuff(first, second)
in failure: true, error_message:
  log_error(message: error_message)
end

More about pattern matching:
https://docs.ruby-lang.org/en/3.0.0/doc/syntax/pattern_matching_rdoc.html

Obligatory gif:

@alexcameron89
Copy link

This seems like a cool use case for Ruby 3 and I love that it's proven backwards compatible in the testing. 👍

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.

None yet

2 participants