interactor icon indicating copy to clipboard operation
interactor copied to clipboard

Adds support for ruby 3.0 pattern matching

Open bonflintstone opened this issue 4 years ago • 1 comments

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:

bonflintstone avatar Aug 09 '21 11:08 bonflintstone

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

alexcameron89 avatar Aug 09 '21 14:08 alexcameron89