Hey. I was trying to add a provider which would enable monad support for Dry Schema and Validation by default but finding this doesn’t error or work:
Hanami.app.register_provider :monads do
I have to manually load these each time within the source code to make this work but am confused why this can’t prepared by the provider?
I ended up adding this to the application configuration. Example:
class App < Hanami::App
See the bottom part of my answer here for how I’ve typically done this: What is the best way to initialize dependencies? - #3 by timriley
tl;dr — create a base class in your app that all contracts, etc. inherit from, and put the global configuration in that file.
That way its only loaded when you need it, courtesy of your app’s contracts using it as a parent class.
I opted to respond more fully in this question but thanks for this. Yeah, I agree, this is a valid solution. A part of me kind of wants to leverage the provider lifecycle more for this because it feels more consistent but maybe that’s just me, though.