Sha256: 511bc45f7f770a5cef0aff4c864da80d8cd6236698974b443852133fa9f019e8

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

module BloodContracts::Core
  # Represents failure in during of Tuple data matching
  class TupleContractFailure < ContractFailure
    # Hash of attributes (name & type pairs)
    #
    # @return [Hash<String, Refined>]
    #
    def attributes
      @context[:attributes]
    end

    # Subset of attributes which are invalid
    #
    # @return [Hash<String, ContractFailure>]
    #
    def attribute_errors
      attributes.select { |_name, type| type.invalid? }
    end

    # Unpacked matching errors in form of a hash per attribute
    #
    # @return [Hash<String, ContractFailure>]
    #
    def unpack_h
      @unpack_h ||= attribute_errors.transform_values(&:unpack)
    end
    alias to_hash unpack_h
    alias to_h unpack_h
    alias unpack_attributes unpack_h
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blood_contracts-core-0.4.0 lib/blood_contracts/core/tuple_contract_failure.rb