MyCase.call(hash) { |on| on.success {} }
serradura opened this issue · 2 comments
serradura commented
MyCase.call(hash) do |on|
on.failure(:foo) {}
on.failure(:bar) {}
on.failure {}
on.success {}
end
MyFlow.call(hash) do |on|
on.failure(:foo) {}
on.failure(:bar) {}
on.failure {}
on.success {}
end
MatheusRich commented
Is there any advantage in doing this, or is it just a different way to make result "pattern matching"?
serradura commented
@MatheusRich the pattern matching will be the same as the result hooks (on_success
, on_failure
). But, this new feature will return the block output instead of the result itself (as the current hooks do).
My idea is to extend the use case instance when it is exposed in a block to forbid the usage of the result hooks. e.g:
class MyModule
def on_success
raise NotImplementedError
end
end
result.extend(MyModule)
What do you think about this idea?