These are chat archives for dry-rb/chat

3rd
Jul 2018
Chris Richards
@cmrichards
Jul 03 2018 12:32
Is it just me, or does anyone else go overkill when creating dry-validation schemas to validate data used by services? I do everything I can to ensure the system won't be put into an invalid state, this includes checking the expired flag of all objects referenced by parameters, etc..
It feels good :-)
Piotr Solnica
@solnic
Jul 03 2018 12:34
@cmrichards it's how it should be
I hope this will become a standard in our community...one day...
Chris Richards
@cmrichards
Jul 03 2018 12:37
What's strange is that I don't think I did a lot of these checks the old fashioned way before I started using dry-validation.
Piotr Solnica
@solnic
Jul 03 2018 12:38
typically, proper type-checks are missing in ruby apps completely
Chris Richards
@cmrichards
Jul 03 2018 12:38
My dry-validation schemas actually feel a lot like tests
Piotr Solnica
@solnic
Jul 03 2018 12:39
ie people would typically do "is this greater than 18" but not "is it an integer that's greater than 18"
then to crash an app you just pass 'foo' as the value :P
Chris Richards
@cmrichards
Jul 03 2018 12:41
Why does this syntax give me an error when it's used in the docs?:
SyntaxError (/home/chrisr/code/work/lims2/app/domains/quoting/services/rename_group.rb:16: syntax error, unexpected ',', expecting ')'
...red(:attempt_id).filled(&:int?, gteq?: 12)
...
Piotr Solnica
@solnic
Jul 03 2018 12:41
&:int? => :int?
Chris Richards
@cmrichards
Jul 03 2018 12:43
thanks. not sure how I've been using &:int? everywhere and getting away with it
Piotr Solnica
@solnic
Jul 03 2018 12:44
well, because with a single predicate it IS valid ruby
filled(&:int?) => filled { int? }
Igor S. Morozov
@Morozzzko
Jul 03 2018 14:01

Hey everyone

So I’ve just read dry-system docs (https://dry-rb.org/gems/dry-system/) and noticed that there’s no dedicated railtie for that.

I really need to integrate dry-system into a huge rails app, so I think I’ll need it. Is there anything to help me started?

I just don’t understand what it means to have a railtie for dry-system. How’s that supposed to look and work?

Piotr Solnica
@solnic
Jul 03 2018 14:03
@Morozzzko https://github.com/dry-rb/dry-system-rails (outdated, but shouldn't be too hard to make it work with latest dry-s)
Igor S. Morozov
@Morozzzko
Jul 03 2018 14:04
Oh that’s awesome! Thank you!
Vasily Kolesnikov
@v-kolesnikov
Jul 03 2018 14:25
@Morozzzko I think it wouldn't be so useful to integrate dry-system into Rails application (especially - huge application). There are some conflicts in a functionality of these libraries, in particular - dependency management and loading control. What problem do you wish to solve with dry-system in your Rails app? Think about support your application in the future. All developers will have to deal with double-paradigm system (Rails+dry-system) which can be very difficult.
Igor S. Morozov
@Morozzzko
Jul 03 2018 14:26
Just to make sure we’re on the same topic: what kind of dependency management do you mean?
Do you mean “my class depends on something”?
Vasily Kolesnikov
@v-kolesnikov
Jul 03 2018 14:27
If you decide to do it anyway, try to build simple empty rails project as a playground and integrate dry-system. Check, how it works with our main libraries which you use, especially with background task runners (Sidekiq, etc).
I mean what is described here http://dry-rb.org/gems/dry-system/ in section "It does a couple of things for you:"
For instance: "Handles $LOAD_PATH configuration" and "Loads needed files using require"
Igor S. Morozov
@Morozzzko
Jul 03 2018 14:29
Well, that kind of dependency management isn’t really a problem here
yeah, that’s exactly what I need it for
Moreover, dry-system will help me merge multiple engines into one, and make them nicer
If I had to choose between maintaining multiple engines and writing code to integrate dry-system into a Rails app, I’d choose the latter. That’s practically my case