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

Allow matching by class instead of just step_name #138

Open
andrepcg opened this issue Nov 9, 2021 · 1 comment
Open

Allow matching by class instead of just step_name #138

andrepcg opened this issue Nov 9, 2021 · 1 comment

Comments

@andrepcg
Copy link

andrepcg commented Nov 9, 2021

Describe the bug

When calling a transaction with a block I can't match the result by the failure class and only by the name of the step.

To Reproduce

class TestOp
  include Dry::Transaction

  step :validate

  def validate(input)
    Contract.new.call(**input).to_monad
  end
end

TestOp.new.call({}) do |m|
  m.failure(Dry::Validation::Result) do |validation|
    # ... <- doesn't match here
  end

  m.failure do
    # ... <- it matches here
  end

Expected behavior

It should match by the resulting class and not just by the step name.

However, if I don't call it with a block and instead I pattern match the result, it works as intended.

op = TestOp.new.call({})
case op
in Dry::Monads::Failure(Dry::Validation::Result => validation)
  # <- it reaches here
end

My environment

  • Affects my production application: NO
  • Ruby version: 2.7.2
  • OS: debian
@saksham-jain
Copy link

saksham-jain commented Jul 11, 2022

Is this issue been taken up, if not I would like to pick it up and fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants