Class: AlertManagement::Alerts::Todo::CreateService
- Inherits:
-
Object
- Object
- AlertManagement::Alerts::Todo::CreateService
- Defined in:
- app/services/alert_management/alerts/todo/create_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(alert, current_user) ⇒ CreateService
constructor
A new instance of CreateService.
Constructor Details
#initialize(alert, current_user) ⇒ CreateService
Returns a new instance of CreateService.
9 10 11 12 |
# File 'app/services/alert_management/alerts/todo/create_service.rb', line 9 def initialize(alert, current_user) @alert = alert @current_user = current_user end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/alert_management/alerts/todo/create_service.rb', line 14 def execute return unless allowed? todos = TodoService.new.mark_todo(alert, current_user) todo = todos&.first return error_existing_todo unless todo success(todo) end |