Files
subtle-storm/app/services/tasks/create.rb
T
2026-03-21 14:48:27 +02:00

27 lines
628 B
Ruby

# frozen_string_literal: true
module Tasks
class Create < ApplicationService
attribute :project_id, :integer
attribute :title, :string
attribute :description, :string
attribute :status_id, :integer
attribute :workflow_id, :integer
validates :project_id, :title, :status_id, :workflow_id, presence: true
delegate :model_name, to: Task
attr_reader :task
def project
@project ||= Project.find(project_id)
end
def perform
@task = project.tasks.build(title:, description:, status_id:, workflow_id:, number: @project.next_task_number)
save @task
end
end
end