Class: Strict::Validators::HashOf
- Inherits:
-
Object
- Object
- Strict::Validators::HashOf
- Defined in:
- lib/strict/validators/hash_of.rb
Instance Attribute Summary collapse
-
#key_validator ⇒ Object
readonly
Returns the value of attribute key_validator.
-
#value_validator ⇒ Object
readonly
Returns the value of attribute value_validator.
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(key_validator, value_validator) ⇒ HashOf
constructor
A new instance of HashOf.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(key_validator, value_validator) ⇒ HashOf
Returns a new instance of HashOf.
8 9 10 11 |
# File 'lib/strict/validators/hash_of.rb', line 8 def initialize(key_validator, value_validator) @key_validator = key_validator @value_validator = value_validator end |
Instance Attribute Details
#key_validator ⇒ Object (readonly)
Returns the value of attribute key_validator.
6 7 8 |
# File 'lib/strict/validators/hash_of.rb', line 6 def key_validator @key_validator end |
#value_validator ⇒ Object (readonly)
Returns the value of attribute value_validator.
6 7 8 |
# File 'lib/strict/validators/hash_of.rb', line 6 def value_validator @value_validator end |
Instance Method Details
#===(value) ⇒ Object
13 14 15 16 17 |
# File 'lib/strict/validators/hash_of.rb', line 13 def ===(value) Hash === value && value.all? do |k, v| key_validator === k && value_validator === v end end |
#inspect ⇒ Object Also known as: to_s
19 20 21 |
# File 'lib/strict/validators/hash_of.rb', line 19 def inspect "HashOf(#{key_validator.inspect} => #{value_validator.inspect})" end |