I’m new to DryRB and wanting to get up to speed on some of the design decisions. The first thing that jumped out at me was the way you use
As Dry::Types is a module, I’d expect to just
but instead we should use
#define_constants method in the source code wasn’t super obvious to me, but it would seem that
#module is just instantiating an anonymous module and
#define_constants is dynamically assigning all the relevant stuff from Dry into it.
Why do it this way?
I can guess that the reason is something like, every time you include this you get a vanilla “copy” of
Dry::Types that can’t have been monkey patched. Is that really all there is to it, or is there some more interesting benefit?
This is just not something we ordinarily see in rubyland so I was curious if I understood what it’s doing and would love to hear what the rationale was
Thanks for the help!