Sha256: 1853755301bf84ad5b7a79f271710538ca47ce09a5798541d3806443a2e84785

Contents?: true

Size: 758 Bytes

Versions: 5

Compression:

Stored size: 758 Bytes

Contents

module BloodContracts::Core
  module Ext
    # Refinement types representation of Sum types composition, extended version
    class Pipe < ::BC::Pipe
      # Sets the default failure_klass to PolicyFailure, to use
      # Tram::Policy::Errors for errors
      self.failure_klass = PolicyFailure

      # @private
      def self.inherited(new_klass)
        new_klass.failure_klass ||= failure_klass
        super
      end

      # Generate an PolicyFailure from the error, also stores the
      # additional scope for Tram::Policy::Errors in the context
      #
      # @param (see BC::Refined#failure)
      # @return [PolicyFailure]
      #
      def failure(*, **)
        @context[:sub_scope] = self.class.name
        super
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blood_contracts-ext-0.1.4 lib/blood_contracts/ext/pipe.rb
blood_contracts-ext-0.1.3 lib/blood_contracts/ext/pipe.rb
blood_contracts-ext-0.1.2 lib/blood_contracts/ext/pipe.rb
blood_contracts-ext-0.1.1 lib/blood_contracts/ext/pipe.rb
blood_contracts-ext-0.1.0 lib/blood_contracts/ext/pipe.rb