These are chat archives for dry-rb/chat

18th
Apr 2016
David Strauß
@stravid
Apr 18 2016 09:00
I just stumbled upon dry-container and I'm not sure in which scenarios such a pattern is best used. Can someone give me reading recommendations to dive into this topic?
Oskar Szrajer
@gotar
Apr 18 2016 09:08
maybe source code of: https://github.com/solnic/rodakase-blog and dry-web
not sure there is any good article, tutorial
Tim Riley
@timriley
Apr 18 2016 10:16
@stravid http://dry-rb.org/gems/dry-component/ also shows how you can use a container to manage an app’s dependencies.
I hope to write some articles/tutorials and share some OSS example apps, but it might be a month or two before they’re all out.
Tim Riley
@timriley
Apr 18 2016 10:17
Yeah, dry-container is pretty great for flexible plugin registries and the like.
The container we use for step adapters in dry-transaction makes stuff like this possible: http://dry-rb.org/news/2016/04/07/dry-transaction-0-6-brings-powerful-new-support-for-custom-step-adapters/
(the part where you inherit from Dry::Transaction::StepAdapters to extend the default container with your own items)
Benjamin Klotz
@tak1n
Apr 18 2016 10:18
@timriley we use it for different api error handlers -> register :facebook, FacebookErrorHandler.new etc etc and then depending on which platform u want to publish it resolves to the proper error handler to see what happened on error cases and with which errors we can deal in a somewhat meaningful way
Tim Riley
@timriley
Apr 18 2016 10:19
Nice. This is a good pattern.
Benjamin Klotz
@tak1n
Apr 18 2016 10:19
I really like it :D
Tim Riley
@timriley
Apr 18 2016 10:19
In the past I’ve done silly things like constantizing strings to try and get class names.
Benjamin Klotz
@tak1n
Apr 18 2016 10:19
yep
const_get inc
Tim Riley
@timriley
Apr 18 2016 10:19
But that’s so fragile. And not flexible.
Registering things with an explicit name is much much better.
Benjamin Klotz
@tak1n
Apr 18 2016 10:20
yep, with const_get its easy to get everything u could possible get as const, and you have to deal with that eg.: use const_get only on proper modules where its allowed etc
with this registering and resolving its pretty explicit and you don't forget that
David Strauß
@stravid
Apr 18 2016 12:15
I see, I will have to do some reading and thinking to figure out how it fits into my understanding of app development. Thanks for the input @tak1n @timriley
Simon Schmid
@sled
Apr 18 2016 13:56
also it's much easier to write stubs ;)