In the company where I work, we use a lot of rails engines, and gems. The gems and engines are the common code across customer projects. The problem we have here is that If one customer want a different behaviors than the standard, then we will overwrite the necessary code. To archive this we do something similar to the following:
# engine/lib/concerns/create_user_service.rb
class Concerns::CreateUserService
...
end
# engine/lib/create_user_service.rb
class CreateUserService
include Concerns::CreateUserService
end
# customer application
class CreateUserService
include Concerns::CreateUserService
def whatever
...
end
end
This solution is not so nice because you will jump always with your IDE to the wrong file and also have some other minor problems. I think that one better solution would be the following:
class Customer::CreateUserService < ::CreateUserService
def whatever
...
end
end
container.register(‘create_user_service’) {.Customer::CreateUserService }
The problem is that the service would already be registered to be the engine.
So, do you have a good idea how to handle this scenario with dry-container and dry-auto_inject or other good suggestions?