Closed flash-gordon closed 4 years ago
@flash-gordon wouldn't it be better to just have ROM.config.inflector
with a helper module for all the classes that needs it? It seems overkillish to inject it through options everywhere.
@solnic I don't know yet. It's kinda experiment, things like this allow to learn more about your code. Overall, I think inflector should be injectable. This may be not an issue for me personally but for Hanami user/developer relying on a global state is a well-known PITA. Code-wise it seems to be not that bad.
@flash-gordon yeah I hear you. It was just an immediate thought I had when I looked at the diff.
@solnic apart from failing specs on 2.4 it's ready to go and I believe it's worth it. The changes are not radical and it brings some flexibility. Of course, it won't work when you instantiate two containers with different inflectors but the same relation classes but this case doesn't exist in the real world I'm sure.
@flash-gordon I'm sorry but I forgot about this PR and now we have a bunch of conflicts. Do you want this in 5.x or just 6.0?
@solnic np, I'll rebase today, it's for 6.0
done
All components that rely on inflector use an injected inflector now rather than using a global
ROM::Inflector
. This makes it possible to configure a custom inflector like that: