Skip to content
Repository Pattern for Ruby
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.idea
lib
spec
.document
.gitignore
LICENSE
README.rdoc
Rakefile
todo.txt

README.rdoc

Treasury

A Ruby implementation of the Repository Pattern, as described in many OO/Patterns books but notably martinfowler.com/eaaCatalog/repository.html and www.infoq.com/resource/minibooks/domain-driven-design-quickly/en/pdf/DomainDrivenDesignQuicklyOnline.pdf (p.51)

From Fowler/Hieatt/Mee: “A system with a complex domain model often benefits from a layer, such as the one provided by Data Mapper, that isolates domain objects from details of the database access code. In such systems it can be worthwhile to build another layer of abstraction over the mapping layer where query construction code is concentrated. This becomes more important when there are a large number of domain classes or heavy querying. In these cases particularly, adding this layer helps minimize duplicate query logic. A Repository mediates between the domain and data mapping layers, acting like an in-memory domain object collection.”

In Treasury, queries are specified using a DSL and turn into Criterion objects, which are then passed to the Repository for matching against the data store. In the case of an SQL data store, they're converted to SQL; in the case of an in-memory store they're matched directly.

Usage

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2009 Alex Chaffee. See LICENSE for details.

Something went wrong with that request. Please try again.