mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:39:52 +01:00
19 lines
387 B
Ruby
19 lines
387 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "dry-initializer"
|
|
|
|
module UseCase
|
|
class Base
|
|
extend Dry::Initializer
|
|
|
|
def self.call(...) = new(...).call
|
|
|
|
def call = raise NotImplementedError
|
|
|
|
private
|
|
|
|
def authorize!(verb, user, record, error_class: Errors::NotAuthorized)
|
|
raise error_class unless Pundit.policy!(user, record).public_send("#{verb}?")
|
|
end
|
|
end
|
|
end
|