Class: BloodContracts::Core::TupleContractFailure
- Inherits:
-
ContractFailure
- Object
- Refined
- ContractFailure
- BloodContracts::Core::TupleContractFailure
- Defined in:
- lib/blood_contracts/core/tuple_contract_failure.rb
Overview
Represents failure in Tuple data matching
Instance Attribute Summary
Attributes inherited from Refined
Instance Method Summary collapse
-
#attribute_contexts ⇒ Hash<String, ContractFailure>
Contexts for subset of attributes which are invalid.
-
#attribute_errors ⇒ Hash<String, ContractFailure>
Subset of attributes which are invalid.
-
#attributes ⇒ Hash<String, Refined>
Hash of attributes (name & type pairs).
-
#unpack_h ⇒ Hash<String, ContractFailure>
(also: #to_hash, #to_h, #unpack_attributes)
Unpacked matching errors in form of a hash per attribute.
Methods inherited from ContractFailure
#errors, #errors_h, #initialize, #match, #merge!, #messages
Methods inherited from Refined
===, and_then, call, inherited, #initialize, #invalid?, match, or_a, #unpack, #valid?
Constructor Details
This class inherits a constructor from BloodContracts::Core::ContractFailure
Instance Method Details
#attribute_contexts ⇒ Hash<String, ContractFailure>
Contexts for subset of attributes which are invalid
24 25 26 |
# File 'lib/blood_contracts/core/tuple_contract_failure.rb', line 24 def attribute_contexts attribute_errors.transform_values!(&:context) end |
#attribute_errors ⇒ Hash<String, ContractFailure>
Subset of attributes which are invalid
16 17 18 |
# File 'lib/blood_contracts/core/tuple_contract_failure.rb', line 16 def attribute_errors attributes.select { |_name, type| type.invalid? } end |
#attributes ⇒ Hash<String, Refined>
Hash of attributes (name & type pairs)
8 9 10 |
# File 'lib/blood_contracts/core/tuple_contract_failure.rb', line 8 def attributes @context[:attributes] end |
#unpack_h ⇒ Hash<String, ContractFailure> Also known as: to_hash, to_h, unpack_attributes
Unpacked matching errors in form of a hash per attribute
32 33 34 |
# File 'lib/blood_contracts/core/tuple_contract_failure.rb', line 32 def unpack_h @unpack_h ||= attribute_errors.transform_values(&:unpack) end |