Dry-system: auto-registering properly cased class names


I’m trying to give dry-system a spin and everything seems to be working great except properly :wink: cased class names – e.g., my STACsConfigRepo class is not being registered under stacs_config_repo (dry-system looks for StacsConfigRepo instead).

I can side-step this by explicitly registering these cases with

register('stacs_config_repo') { STACsConfigRepo.new }

but I was wondering whether there is a better option. I have quite a few classes named like this (beggining with STAC and SC) and would much rather not have to special-case all of them.

A cursory look at the way dry-system resolves this (unsing the inflecto gem to create the class name from the key) seems to suggest this is not something easily fixable, but just wanted to double-check / fish for ideas.

Thanks so much for dry-system! I’m looking forward to rooting all of the explicit require_relatives and hard-coded class names from my code. :+1:

Hey hey!

I’m happy to see you here :slight_smile: This is actually something that we can workaround by switching to Dry::Core::Inflector (I’ve no idea why I used Inflecto directly). The difference is that Dry::Core::Inflector can be configured with different inflection backends, so ie you could use ActiveSupport::Inflector (sad truth is that it’s still the best solution) and add custom inflection for your classes.

FWIW, we’re working on dry-inflector gem which eventually will be ready, and it will support adding custom inflections (and won’t have monkey-patches, and will be more flexible, and faster, and nicer).


ps. please report an issue about the fact we’re using inflecto directly, this is a mistake and we gotta fix.