Class: FastCqrs::Authorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/fast_cqrs/authorizer.rb

Overview

A base Authorizer class used to validate the access to the given resource an easy to use hash. Usage: Inherit and override the #authorize method

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(klass) ⇒ Object



11
12
13
14
15
16
# File 'lib/fast_cqrs/authorizer.rb', line 11

def self.inherited(klass)
  super
  klass.class_eval do
    include Dry::Monads[:result, :do]
  end
end

Instance Method Details

#call(subject: nil, auth: nil) ⇒ Object



18
19
20
21
22
# File 'lib/fast_cqrs/authorizer.rb', line 18

def call(subject: nil, auth: nil)
  return Success() if authorize(subject, auth)

  fail!
end