TheProlog / prolog-use_cases

Use-case layer for Meldd/Prolog application.
0 stars 0 forks source link

Retrieve entity for Article matching specified search term(s) #13

Closed jdickey closed 8 years ago

jdickey commented 8 years ago

Use case RetrieveArticle, which takes at least one identifier (e.g., title, author) returns a Prolog::Core::Article entity with the previously-persisted Article matching the search term(s).

This sounds pretty generic and straightforward, doesn't it? The specific impetus for this was item 9 in the "User-Eye View" feature list in Issue #1, which said that the use cases needed to support being able to

view the article page for the newest article

Possible Error Conditions

  1. No match found: no Article matching the search term(s) was found or, in future, no matching Article is accessible to the current user;
  2. Non-specific search terms: the search terms were insufficiently specific to isolate one specific Article matching the request.

    Relation to SummariseContent

The SummariseContent use case already has a nested class called ArticleLister, which simply retrieves all Articles from a repository. It exercises the #all method on the object passed into SummariseContent#initialize as its :repository parameter.

Repository Interface

This use case requires that the :repository parameter passed to RetrieveArticle#initialze must have a #where method, taking an arbitrary number of field matchers as a Hash. That Hash will have field identifiers as keys (e.g., :title) and values either as simple values or as lambdas taking a single parameter (the field value for a record) and returning true or false signifying whether the specified value meets the search condition implemented by the lambda.