Sha256: f3267a73199d368da63fa28d60bf2185bda1d52e382bc576f99a89e094251633

Contents?: true

Size: 713 Bytes

Versions: 6

Compression:

Stored size: 713 Bytes

Contents

# typed: true
# frozen_string_literal: true

require 'dry/monads/all'
require 'clean_architecture/entities/failure_details'

module CleanArchitecture
  module Checks
    class Authorization
      extend Forwardable

      def result
        if authorized?
          Dry::Monads::Success(true)
        else
          failure_details = Entities::FailureDetails.new(
            message: failure_message,
            other_properties: {},
            type: 'unauthorized'
          )
          Dry::Monads::Failure(failure_details)
        end
      end

      protected

      def failure_message
        'Unauthorized'
      end

      def authorized?
        raise NotImplementedError
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
clean-architecture-5.0.1 lib/clean_architecture/checks/authorization.rb
clean-architecture-4.0.1 lib/clean_architecture/checks/authorization.rb
clean-architecture-4.0.0 lib/clean_architecture/checks/authorization.rb
clean-architecture-3.0.2 lib/clean_architecture/checks/authorization.rb
clean-architecture-3.0.1 lib/clean_architecture/checks/authorization.rb
clean-architecture-3.0.0 lib/clean_architecture/checks/authorization.rb