Class: Stannum::Contracts::HashContract
- Inherits:
-
MapContract
- Object
- Stannum::Constraints::Base
- Base
- Stannum::Contract
- MapContract
- Stannum::Contracts::HashContract
- Defined in:
- lib/stannum/contracts/hash_contract.rb
Overview
A HashContract defines constraints on an hash’s values.
Direct Known Subclasses
IndifferentHashContract, Parameters::SignatureContract, ParametersContract
Constant Summary
Constants inherited from Stannum::Constraints::Base
Stannum::Constraints::Base::NEGATED_TYPE, Stannum::Constraints::Base::TYPE
Instance Attribute Summary
Attributes inherited from Stannum::Constraints::Base
Instance Method Summary collapse
-
#initialize(allow_extra_keys: false, key_type: nil, value_type: nil, **options, &block) ⇒ HashContract
constructor
A new instance of HashContract.
-
#key_type ⇒ Stannum::Constraints::Base, ...
The expected type for the keys in the Hash, if any.
-
#value_type ⇒ Stannum::Constraints::Base, ...
The expected type for the values in the Hash, if any.
Methods inherited from MapContract
#add_key_constraint, #allow_extra_keys?, #expected_keys, #with_options
Methods inherited from Stannum::Contract
#add_constraint, #add_property_constraint
Methods inherited from Base
#==, #add_constraint, #concat, #does_not_match?, #each_constraint, #each_pair, #errors_for, #match, #matches?, #negated_errors_for, #negated_match
Methods inherited from Stannum::Constraints::Base
#==, #clone, #does_not_match?, #dup, #errors_for, #match, #matches?, #message, #negated_errors_for, #negated_match, #negated_message, #negated_type, #type, #with_options
Constructor Details
#initialize(allow_extra_keys: false, key_type: nil, value_type: nil, **options, &block) ⇒ HashContract
Returns a new instance of HashContract.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/stannum/contracts/hash_contract.rb', line 96 def initialize( allow_extra_keys: false, key_type: nil, value_type: nil, **, &block ) super( allow_extra_keys: allow_extra_keys, key_type: key_type, value_type: value_type, **, &block ) end |
Instance Method Details
#key_type ⇒ Stannum::Constraints::Base, ...
Returns the expected type for the keys in the Hash, if any.
114 115 116 |
# File 'lib/stannum/contracts/hash_contract.rb', line 114 def key_type [:key_type] end |
#value_type ⇒ Stannum::Constraints::Base, ...
Returns the expected type for the values in the Hash, if any.
120 121 122 |
# File 'lib/stannum/contracts/hash_contract.rb', line 120 def value_type [:value_type] end |