Created
October 11, 2017 10:21
-
-
Save davydovanton/d8e9bd390b2f2e496a49011a7be32913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Service | |
include Dry::Matcher.for(:call, with: Dry::Matcher::EitherMatcher) | |
include Dry::Monads::Either::Mixin | |
def call(payload) | |
# ... | |
Right(payload) | |
end | |
end | |
Servise.new.call({ ... }) do |m| | |
m.success do |payload| | |
# ... | |
end | |
m.failed do |payload| | |
# ... | |
end | |
end | |
# когда вся логика на месте и понятно как и на какие шаги разделить объект | |
class Service | |
include Dry::Transaction | |
step :step1 | |
# ... | |
def step1(payload) | |
# ... | |
Right(payload) | |
end | |
end | |
Servise.new.call({ ... }) do |m| | |
m.success do |payload| | |
# ... | |
end | |
m.failed do |payload| | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment