Retrospring/lib/use_case/question/destroy.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
497 B
Ruby
Raw Normal View History

2022-07-07 09:38:04 -07:00
# frozen_string_literal: true
module UseCase
module Question
class Destroy < UseCase::Base
option :question_id, type: Types::Coercible::Integer
option :current_user, type: Types::Instance(::User)
def call
question = ::Question.find(question_id)
raise Errors::Forbidden unless current_user&.mod? || question.user == current_user
question.destroy!
2022-07-23 06:33:28 -07:00
{
status: 204,
resource: nil,
}
2022-07-07 09:38:04 -07:00
end
end
end
end