class TodoService

Overview

TodoService

A class that represents a service for managing todos.

Initialization

Methods

Defined in:

domain/services/todo_services.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(repository : TodoRepository, output_port : TodoOutputPort) #

Initializes a new instance of the TodoService class.

@param repository [TodoRepository] An instance of the TodoRepository class that provides methods for accessing and manipulating todos. @param output_port [TodoOutputPort] An instance of the TodoOutputPort class that provides methods for displaying todos.


[View source]

Instance Method Detail

def all_todos : Array(Todo) #

Retrieves all todos from the repository and displays them.

@return [Array(Todo)] An array of Todo objects representing all the todos retrieved from the repository.


[View source]
def create_todo(title : String) : Todo #

Creates a new todo with the given title, saves it to the repository, and displays the created todo.

@param title [String] The title of the new todo. @return [Todo] A Todo object representing the newly created todo.


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

Retrieves a todo with the given id from the repository and displays its details.

@param id [String] The id of the todo to retrieve. @return [Todo?] A Todo object representing the todo with the given id, or nil if no todo is found.


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

Marks the given todo as completed and displays the completed todo.

@param todo [Todo] The todo to mark as completed. @return [Todo] A Todo object representing the todo that was marked as completed.


[View source]
def output_port : TodoOutputPort #

[View source]
def output_port=(output_port : TodoOutputPort) #

[View source]
def repository : TodoRepository #

[View source]
def repository=(repository : TodoRepository) #

[View source]