Rails development and dry-system

I’m working on breaking a part a rails app and making use of dry-system. Everything is working great so far, except I cannot figure out how to get it working with Rails’ constant reloading in development. Has anyone done this successfully or have suggestions on where I might start?

Thanks,
Aaric

What I’ve come up with so far is defining a require method on the module like such:

def self.require(path)
  if defined?(Rails)
    require_dependency(path)
  else
    require(path)
  end
end

and using that for my require statements. Would love to hear thoughts on doing it this way.

This is super outdated, but we have a railtie for dry-system right here https://github.com/dry-rb/dry-system-rails Maybe it’d be worth seeing if a proper setup for code reloading could be added to this railtie.

This is a very rails-specific problem so monkey-patching Container is going to be the best solution (and of course extracting the require part into a separate method that can be overridden), simply because the alternative is to make the library more complex just to satisfy this one use case. Maybe in the future, we will discover that having a configurable “source loader” is useful, but for now, this is the only case. I’m more than happy to give you commit access to dry-system-rails and you can do whatever you need to do in order to make it work for you and others.

@solnic Thank you. I would be happy to work on the Railtie changes.

It sounds like you are amenable to having me open a PR against dry-system to extract a method around the require stament.

Is that correct?

Yes, that’s what I implicitly meant too :smile:

Thanks. I will go ahead and do that.

@solnic Thanks for accepting the PR!

Are you still amenable to granting me commit access to dry-system-rails?

Do you feel like it is something that should be part of the dry eco-system or would you prefer it to be managed/maintained by another group/org?