redding/mr — pull request #162 by jcredding (2014-01-07 22:16:16+00:00)
Title: Add `find` method to `ReadModel`

This adds a `find` method to `ReadModel`. This will allow querying
for a specific record in the collection. It will use
ActiveRecord's `find` method on the relation. The relation itself
is only built from a subset of the read model's expressions. It
will not use any `where`, `order`, `limit` or `offset` expressions.
Furthermore, it will use ActiveRecord's `except` to try and remove
any `where`, `order`, `limit` or `offset` expressions that got
applied, possibly through a generic `merge`. This is because
`order` doesn't matter when selecting a specific record and
`where`, `limit` and `offset` can remove the record from the
results.

Closes #142

@kellyredding - I updated to the latest version of Ardb, but I actually decided to not use the new features that I added to the relation spy. I was going to use some of ActiveRecord's methods to remove any `where`, `order`, `limit` and `offset` that were added to the relation with the `find`. The only case where this can happen is if a generic `merge` adds one of the above. I decided to not try and force the relation to not have the black listed expression types. I figure if you aren't telling the `ReadModel` about them and are using a `generic` merge, either you want them to be applied with your `find` or you are responsible for turning them on/off. I preferred this because it's the most flexible. If you use `ReadModel` interface, it will work how the 99% should. If you go your own way using a `merge`, then you have full control on what you want the relation to be. Anyway, just wanted to try and explain this.