Skip to content

Latest commit

 

History

History
47 lines (41 loc) · 1.5 KB

README.md

File metadata and controls

47 lines (41 loc) · 1.5 KB

ActiveRecord Repository

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.

TODO

  • Loading
    • Loading relations
      • Avoiding N+1 queries
  • 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
  • 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
  • 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
  • More validations