You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 18, 2018. It is now read-only.
Having trying forcing DDD onto Rails in the past, I'm wondering if you guys too bumped into the following impedance mismatch (from the code looks like you did).
The idea is, that instead of doing a static SomeRepo.save and statically swapping a data provider you should do a some_repo.save where some_repo is an instance of a repository instantiated and injected per X, where X might be:
session (request start, instantiate, throw away at request end. best practice)
request (everytime you want to do something to a domain object)
application lifetime (singleton, dangerous)
This enables the contract for the controller to just requires an instance that quacks like a repository, and the dependency isn't hard-coded as a static dependency. Makes easier testing, puppies happy etc.
These almost always requires incorporating IoC, which by popular opinion "isn't needed in a dynamic language such as Ruby".