Closed solnic closed 8 years ago
There's also #331 that wasn't finish, we could probably make it completely flexible by allowing passing a custom dir/constant resolver
@solnic Wondering about the api for custom dir/constant resolver. Do you think we should add another parameter or change existing one :namespace
to allow custom resolver? If we use the same parameter name, can we have some kind of type that has to inherit from base strategy?
Let's hold off with any further improvements until somebody asks for something more customized, then we can revisit.
Hi @solnic !
I wrote some months ago about my case on gitter. I don't like classic separation components by type (f.e. directories app/relations/users.rb
, analogical mappers
and commands
) because IMO better, more efficient way is separation by business feature(f.e. app/contexts/user/relation.rb
, app/contexts/post/relation.rb
). I created one, quite big project with that approach and it saved my life(and common sense :D ). I used ROM v1, and created a custom registration of components cause that kind of directories configuration was unsupported.
I wonder if there is a way to smart auto-register components in that configuration or maybe it's so significant difference between approaches?
Currently
ROM::Configuration#auto_registration
supports:namespace
option but it is only an on/off toggle, when it's turned on, then the first directory under provided path is treated as the namespace, then we assume there arerelations
,commands
andmappers
sub-dirs under that namespace dir. ieauto_registration('lib/persistence', namespace: true)
will look forlib/persistence/(relations|mappers|commands)/**/*.rb
and assumes module hierarchy isPersistence::(Relations|Mappers|Commands::*
.So, it'd be nice to make it more flexible, so that we can do this:
auto_registration('lib/persistence', namespace: true)
- current behavior is maintainedauto_registration('lib/persistence', namespace: false)
- current behavior is maintainedauto_registration('lib/persistence', namespace: 'MyApp::MyPersistence')
- a string can be set as the namespace, in which case the root dir name is not going to be used as the namespace. So it's gonna loadlib/persistence/(relations|mappers|commands)/**/*.rb
and assume that things are defined underMyApp::MyPersistence
namespace ielib/persistence/relations/users
==MyApp::MyPersistence::Relations::Users
/cc @janjiss
Closes #338