These are chat archives for dry-rb/chat

28th
May 2016
Jacek Brożek
@jac33k
May 28 2016 08:45
Hey there! @solnic great idea with inviting to contributing via Twitter! I'm using Rails mostly for JSON APIs and I think I could've seen few use cases (especially schemes) for dry-v. I'll get back here with few ideas here latest this weekend :)
(this smiling emoji is a bit too joyful)
Piotr Solnica
@solnic
May 28 2016 10:50
@jac33k sweet! there are lots of nice use cases for this lib but rails requires additional work, hence I asked for help. I believe many people can benefit when we make it work with rails OOTB and provide some conveniences and conventions around its usage in Rails :)
Piotr Solnica
@solnic
May 28 2016 12:49
@elskwid hey Don, sorry for this late reply. That's awesome to hear. Let's chat about this
Don Morrison
@elskwid
May 28 2016 17:13
@solnic no problem. Yes, we have been slowly moving legacy cruft into little corners of the app so we can start to use dry libs.
That latest move was a post-rails 4 upgrade, we finally removed all the attr_protected garbage, we’re on strong params but they’re behind some classes with simple interfaces so we can swap out the implementation
Piotr Solnica
@solnic
May 28 2016 18:07
@elskwid yummy
we're gonna push a major release of dry-v in a couple of weeks, this will be a good moment to try it out
Don Morrison
@elskwid
May 28 2016 18:12
shove the mess in the corner, deal with the mess later
Excellent!
@solnic gotta love that kind of work
It’s what careers are made of
Piotr Solnica
@solnic
May 28 2016 18:15
this type of refactoring is really healthy for an app, even if you don't change how it works under the hood (ie you still use the same libs) what you achieve is a narrower, app-specific interface :)
Don Morrison
@elskwid
May 28 2016 18:15
yessir!
give it a name, give it a place, rinse, repeat
Piotr Solnica
@solnic
May 28 2016 18:15
:)
Don Morrison
@elskwid
May 28 2016 18:15
ha
Chase Gilliam
@Ch4s3
May 28 2016 18:49

@solnic re:

defining schemas in the controllers would be too messy I think, so we could have some simpler and more concise API that would set up validation schemas behind the scenes and cache them (rebuilding schemas on each request makes no sense)

What I do in rails w/ dry-validation is set up a validations folder with schemas in it. What do you think the advantage would be setting them up behind the scenes?

Piotr Solnica
@solnic
May 28 2016 18:55
oh I was
(sorry pre mature send is premature)
So, I was thinking from a rails user who is used to the slim strong-params api point of view
Andrew Kozin
@nepalez
May 28 2016 18:56
@solnic could you help, please. I cannot figure out how to idiomatically check whether some object is a dry-type
Piotr Solnica
@solnic
May 28 2016 18:57
@nepalez first of all, don't :)
did I help? :D
Don Morrison
@elskwid
May 28 2016 18:57
so helpful
Andrew Kozin
@nepalez
May 28 2016 18:57
in a sense, yes :)
well, I could back on #[] interface
Piotr Solnica
@solnic
May 28 2016 18:59
you should
Andrew Kozin
@nepalez
May 28 2016 18:59
I'd like to drop support for any types except for dry-types in dry-initializer (my bad, this was a mistake)
Piotr Solnica
@solnic
May 28 2016 19:00
every time you see is_a? in ruby you should consider this as a code smell, I hate it every time I use it :laughing:
you should just rely on #call API
#[] is an alias
Andrew Kozin
@nepalez
May 28 2016 19:02
yes, you're right. this is why I do not think any more that modules and classes are good candidates for types ;)
Chase Gilliam
@Ch4s3
May 28 2016 19:03
We could hang schemas on the model. But what about non-ar backed API endpoints?
Piotr Solnica
@solnic
May 28 2016 19:14
we could have schemas infered from models, but models shouldn't know about schemas
ie it should be possible to have a single schema for a whole model, including nested stuff for associations
dry-v supports optional keys, so that should be possible
and since we're more concerned with defining valid params (from a request pov) only, the we can do it like that
Chase Gilliam
@Ch4s3
May 28 2016 19:18
Interesting. I'll give that some thought