Condition Finder Design - LifebookerInc/api_resource GitHub Wiki

Condition

Conditions are there simply to build up a list of conditions. They do not have any idea how to perform a find, get data, or convert raw data into objects.

Finders

Finders actually perform a find of some data. It might be associated objects, initial objects, with conditions, or any number of other things. They make use of proxies in that the conditions the proxy generates get sent to them.

The base class finder should be implemented as a finder, but is not currently.

Example

Say we have the chain Base.active.liked.friends where active and liked are scopes, and friends is an association.

Base.active returns a Condition, with whatever finder options are required for the active scope set.

Calling .liked on the condition from the previous line then adds the liked scope options to the condition chain. This is done by returning a new condition object, which is the combination of the original active scope and the liked scope.

When we then call the .friends association on the condition, and that ends it, since we do not currently support adding conditions on associations.

Base.active.liked.friends ==> Condition(active).liked.friends ==> Condition(active, liked).friends ==> Friends(All Base which are both "liked" and "active") ==> the friends of all base objects which are both liked and active.