Task create and update
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Tasks
|
||||
class Update < ApplicationService
|
||||
attribute :id, :integer
|
||||
attribute :title, :string
|
||||
attribute :description, :string
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
delegate :model_name, to: Task
|
||||
|
||||
def persisted? = true
|
||||
|
||||
def perform(task)
|
||||
@task = task
|
||||
@id = task.id
|
||||
@task.assign_attributes(title:, description:)
|
||||
save @task
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user