class BloodContracts::Core::TuplePolicyFailure

Represents failure in Tuple data matching

Public Instance Methods

attribute_errors() click to toggle source

Subset of attributes which are invalid

@return [Hash<String, PolicyFailure>]

# File lib/blood_contracts/core/tuple_policy_failure.rb, line 16
def attribute_errors
  attributes.select { |_name, type| type.invalid? }
end
attribute_messages() click to toggle source

Subset of attributes which are invalid

@return [Hash<String, PolicyFailure>]

# File lib/blood_contracts/core/tuple_policy_failure.rb, line 24
def attribute_messages
  attribute_errors.transform_values!(&:messages)
end
attributes() click to toggle source

Hash of attributes (name & type pairs)

@return [Hash<String, Refined>]

# File lib/blood_contracts/core/tuple_policy_failure.rb, line 8
def attributes
  @context[:attributes]
end
to_h()
Alias for: unpack_h
to_hash()
Alias for: unpack_h
unpack_attributes()
Alias for: unpack_h
unpack_h() click to toggle source

Unpacked matching errors in form of a hash per attribute

@return [Hash<String, PolicyFailure>]

# File lib/blood_contracts/core/tuple_policy_failure.rb, line 32
def unpack_h
  @unpack_h ||= attribute_errors.transform_values(&:unpack)
end
Also aliased as: to_hash, to_h, unpack_attributes