These are chat archives for dry-rb/chat

10th
Jan 2018
Chris Richards
@cmrichards
Jan 10 2018 00:16
hmmm... I wonder how safe it is to add a before_action for params = params.to_h
Vasily Kolesnikov
@v-kolesnikov
Jan 10 2018 08:47
Hi! Is it possible to configure dry-inflector to camelize('rss') as 'RSS'?
Gustavo Caso
@GustavoCaso
Jan 10 2018 08:53
There is an issue open at the moment for that sort of problems
dry-rb/dry-inflector#16
dry-rb/dry-inflector#19
Chris Richards
@cmrichards
Jan 10 2018 22:23
What does the exclamation point do here? result.value!
Success / Failure are better than Right / Left. Good change :-)
is result.value! the new result.value ?
why?
Nikita Shilnikov
@flash-gordon
Jan 10 2018 22:27
@cmrichards because Failure#value! raises an error
Chris Richards
@cmrichards
Jan 10 2018 22:28
It raises an error if the result is a Failure?
Nikita Shilnikov
@flash-gordon
Jan 10 2018 22:28
yes
for extracting failing part there is Failure#error
Chris Richards
@cmrichards
Jan 10 2018 22:30
ok neat. I've just added a call! method to my service class (in addition to the call method) that uses the EitherMatcher.
what does Failure#error return?
i'll look into this
Nikita Shilnikov
@flash-gordon
Jan 10 2018 22:31
the description of a failing case, e.g. Failure(:user_not_found).error # => :user_not_found
it's rearly needed
you generally use fmap/bind and or
because monads are all about composition
Chris Richards
@cmrichards
Jan 10 2018 22:33
I'm just using the Either matcher http://dry-rb.org/gems/dry-matcher/either-matcher/
Nikita Shilnikov
@flash-gordon
Jan 10 2018 22:34
it's fine, it wraps all these methods with a DSL so you don't bother
Chris Richards
@cmrichards
Jan 10 2018 22:34
So... in my class that uses the EitherMatcher I can return Failure(:bla_bla)? Currrently I usually return errors Failure({errors: ..., })
Nikita Shilnikov
@flash-gordon
Jan 10 2018 22:36
you certainly can, really depends on what suits you more
Chris Richards
@cmrichards
Jan 10 2018 22:47
@flash-gordon I can't include this in my Service superclass - I have to add it to each sub-class otherwise it doesn't work. Is there a way around that?
class DoThing < Service 
     include Dry::Matcher.for(:call, with: Dry::Matcher::ResultMatcher)
Nikita Shilnikov
@flash-gordon
Jan 10 2018 22:48
def self.inherited(base)
  super
  base.include(Dry::Matcher.for(:call, with: Dry::Matcher::ResultMatcher))
end
Chris Richards
@cmrichards
Jan 10 2018 22:48
doh...
thanks
Nikita Shilnikov
@flash-gordon
Jan 10 2018 22:49
np
Chris Richards
@cmrichards
Jan 10 2018 22:51
although that's easy to implement yourself - so perhaps not