Class: Stannum::Constraints::Hashes::IndifferentExtraKeys
Overview
Constraint for validating the keys of an indifferent hash-like object.
When using this constraint, the keys must be strings or symbols, but it does not matter which - a constraint configured with string keys will match a hash with symbol keys, and vice versa.
Constant Summary
Constants inherited from ExtraKeys
ExtraKeys::NEGATED_TYPE, ExtraKeys::TYPE
Constants inherited from Base
Base::NEGATED_TYPE, Base::TYPE
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#expected_keys ⇒ Set
The expected keys.
Methods inherited from ExtraKeys
#does_not_match?, #errors_for, #initialize, #matches?
Methods inherited from Base
#==, #clone, #does_not_match?, #dup, #errors_for, #initialize, #match, #matches?, #message, #negated_errors_for, #negated_match, #negated_message, #negated_type, #type, #with_options
Constructor Details
This class inherits a constructor from Stannum::Constraints::Hashes::ExtraKeys
Instance Method Details
#expected_keys ⇒ Set
Returns the expected keys.
29 30 31 32 33 34 35 |
# File 'lib/stannum/constraints/hashes/indifferent_extra_keys.rb', line 29 def expected_keys keys = [:expected_keys] return indifferent_keys_for(keys) unless keys.is_a?(Proc) indifferent_keys_for(keys.call) end |