interactor
interactor copied to clipboard
Adds support for ruby 3.0 pattern matching
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:

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