Dry-system documentation suggestion


When ‘auto-import’ components, one should carefully read the Documentation here.

The paragraph that say

lib/api/client resolves to API::Client class with identifier ‘api.client’.

Could be better illustrated with a folder structure that show a

     |- lib
        |- api

and client.rb

   Module Api
        class Client

Also it seems to me that on the last code of the lib/persistence/user_repo.rb
the class should be in the persistence module.


# lib/persistence/user_repo.rb
require 'import'
module Persistence
  class UserRepo
    include Import['persistence.db']

    def find(conditions)

as if someone would like to use it from somewhere else, it would be registered as persistence.user_repo
but when instantiating the component.instance it won’t find the proper Persistent::UserRepo constant defined.

I struggled a long moment, before finding why an ‘auto-import’ class, was reporting something like ‘constant Api not foundfor a component in a/lib/api/client.rb’ under key 'api.client' until I wrapped the Client class into the proper Api module as the directory structure dictate it.

Or the loader should try harder :wink:


Thanks, I just fixed it.

I’m actually planning to investigate if we can inspect files and see what class constants they define, but I don’t have good feelings about this :slight_smile:


I fact, I think imposing this Folder to Module hierarchies mapping make sense.

It not a high cost to pay and it play well with the ‘namespacing’ concept.

As it on the ‘convention’ over configuration, it seems reasonable to respect it.

However, the documentation could emphasise this a little bit.