Using Dry System Auto Register and ActiveSupport::Inflections


#1

I’m currently attempting to introduce dry-system to rails, but I am having issues with auto registrar of dry-system with as my classes are inflected with ActiveSupport::Inflections. Is there a way to configure inflections with dry-system auto-register functionality? By the way, this is my current workaround solution in Rails, but using inject will still invoke inflecto and cause issues.

class Container < Dry::System::Container
  configure do |config|
    config.root = Rails.root
  end
  load_paths!('lib/components')
end

dir = Rails.root.join('lib/components')
Dir["#{dir}/**/*.rb"].each do |filename|
pathname = Pathname.new(filename)
                   .relative_path_from(dir)
                   .sub_ext('')
                   .to_path
require pathname
Container.register(pathname.tr('/', '.'), pathname.camelize.constantize.new)

#2

Not sure if this is helpful, but we switched to dry-inflector in dry-system 0.9.


#3

Thanks for the reply. Unfortunately, I will still need to use a custom loader unless I copy my inflections to Dry::Inflector. A possible approach would be to allow configuration of an inflection backend for Dry::System. Would that be possible?


#4

Yes, this will be added prior 1.0.0. We definitely need an inflector that is configurable.