This is an implementation of the repository pattern for ActiveRecord. Using this allows splitting the domain model and persistence classes.
WARNING: This is currently merely a proof of concept. This means that testing and refactoring have often been put on the back burner.
- Loading
- Loading relations
- Avoiding N+1 queries
- Loading relations
- Saving
- Saving relations
- Keep a registry of the repository classes
- Indexed by the classes they map to
- Use this to find repository class for relations
- Caveat: What if there are 2 repositories for a relation we're looking for?
- Need a way to specify that somewhere
- In the repository is the only place that makes sense
- Need a way to specify that somewhere
- Caveat: What if there are 2 repositories for a relation we're looking for?
- Probably need to restrict other calls to Repository
User::Repository.create
- Entity#initialize and #update should basically be the same
- Maybe the only difference is that initialize will set things to
nil
- They could use a lot of refactoring
- Maybe the only difference is that initialize will set things to
- Relations between entities
- belongs_to
- has_many
- has_one
- has_many through:
- Cascading deletions
- Entity#changed?
- Identity mapping
- Use module builder pattern in ActiveModel.entity
- Add more options
- Use module factory (and module builder) pattern in ActiveRecord.repository
- Add options
- Setting entity class
- Setting table_name
- Setting a different primary key than
id
- Maybe define indexes
- Add options
- More validations