All Projects → boochtek → activerecord-repository

boochtek / activerecord-repository

Licence: MIT license
Implementation of the repository pattern for ActiveRecord, splitting domain model and persistence classes

Programming Languages

ruby
36898 projects - #4 most used programming language

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].