retrospring/lib/use_case/relationship/destroy.rb
Karina Kwiatek d67ae1eb19 Only accept users to relationship use cases
Dry Types was having issues with taking either an object or string so it's easier to deal with just passing in an object directly
2022-06-13 11:56:34 +02:00

26 lines
551 B
Ruby

# frozen_string_literal: true
require "use_case/base"
require "errors"
module UseCase
module Relationship
class Destroy < UseCase::Base
option :source_user, type: Types.Instance(::User)
option :target_user, type: Types.Instance(::User)
option :type, type: Types::RelationshipTypes
def call
source_user.public_send("un#{type}", target_user)
{
status: 204,
resource: nil,
extra: {
target_user: target_user
}
}
end
end
end
end