Retrospring/lib/use_case/base.rb

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

20 lines
387 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2022-07-23 01:02:06 -07:00
require "dry-initializer"
module UseCase
class Base
extend Dry::Initializer
def self.call(...) = new(...).call
def call = raise NotImplementedError
2023-02-10 02:34:55 -08:00
private
def authorize!(verb, user, record, error_class: Errors::NotAuthorized)
raise error_class unless Pundit.policy!(user, record).public_send("#{verb}?")
end
end
2022-07-23 01:02:06 -07:00
end