module Laspatule::Repositories::Ingredients
Direct including types
Defined in:
laspatule/repositories/ingredients.crInstance Method Summary
-
#create(ingredient : Models::CreateIngredient) : Int32
Creates a new ingredient and returns its id.
-
#get_by_id(id : Int32) : Models::Ingredient
Gets an ingredient by id.
-
#search_by_name(name : String, page_size : Int32, next_page previous_page : String | Nil = nil) : Models::Page(Models::Ingredient)
Gets an ingredient by name.
Instance Method Detail
abstract
def create(ingredient : Models::CreateIngredient) : Int32
#
Creates a new ingredient and returns its id.
If an ingredient with the same name already exists, raises a
DuplicatedIngredientError
.
abstract
def get_by_id(id : Int32) : Models::Ingredient
#
Gets an ingredient by id.
If the ingredient is not found, raises an IngredientNotFoundError
.
abstract
def search_by_name(name : String, page_size : Int32, next_page previous_page : String | Nil = nil) : Models::Page(Models::Ingredient)
#
Gets an ingredient by name.
Any ingredient containing the given name will be returned. The ingredients are ordered by the size of the name string, shortest first.
This is a paginated query, see Models::Page
for pagination instructions.