class InMemoryTodoRepository

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.cr

Instance Method Summary

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

def find_all : Array(Todo) #

Returns all the todos in the repository.

@return [Array(Todo)] The list of all todos.


[View source]
def find_by_id(id : String) : Todo | Nil #

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.


[View source]
def save(todo : Todo) : Todo #

Saves a new todo to the repository.

@param todo [Todo] The todo to save. @return [Todo] The saved todo.


[View source]
def todos : Array(Todo) #

[View source]
def todos=(todos : Array(Todo)) #

[View source]