class InMemoryTodoRepository
- InMemoryTodoRepository
- TodoRepository
- Reference
- Object
Overview
InMemoryTodoRepository is a class that represents an in-memory implementation of a TodoRepository. It extends the TodoRepository class and provides methods for finding and saving todos.
Example usage:
repository = InMemoryTodoRepository.new
todos = repository.find_all
todo = repository.find_by_id(1)
saved_todo = repository.save(todo)
@property todos [Array(Todo)] The array of todos in the repository.
Defined in:
application/repositories/inmemory.crInstance Method Summary
-
#find_all : Array(Todo)
Returns all the todos in the repository.
-
#find_by_id(id : String) : Todo | Nil
Finds a todo by its ID.
-
#save(todo : Todo) : Todo
Saves a new todo to the repository.
- #todos : Array(Todo)
- #todos=(todos : Array(Todo))
Instance methods inherited from class TodoRepository
find_all : Array(Todo)
find_all,
find_by_id(id : String) : Todo | Nil
find_by_id,
save(todo : Todo) : Todo
save
Instance Method Detail
Returns all the todos in the repository.
@return [Array(Todo)] The list of all todos.
Finds a todo by its ID.
@param id [String] The ID of the todo to find.
@return [Todo?] The todo with the matching ID, or nil
if not found.
Saves a new todo to the repository.
@param todo [Todo] The todo to save. @return [Todo] The saved todo.