forked from hanami/model
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Per hanami#550, the HasMany interface does not line up with Hanami's guides. Prior to this commit, the following is invalid as HasMany does not implement #one. ```ruby class AuthorRepository < Hanami::Repository associations do has_many :books end def find_book(author, id) book_for(author, id).one end private def book_for(author, id) assoc(:books, author).where(id: id) end end ``` This implementation is based on a couple of others, notably ROM's and Ecto's (Elixir). I opted to name the raised error MultipleResultsError, which is the exact name used by Ecto, because I feel it bears a semantic relationship to the name of the method from which raises it.
- Loading branch information
1 parent
3ac27f7
commit 870f7af
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters