Class: ValueSemantics::ArrayOf
- Inherits:
-
Object
- Object
- ValueSemantics::ArrayOf
- Defined in:
- lib/value_semantics.rb
Overview
Validator that matches arrays if each element matches a given subvalidator
Instance Attribute Summary collapse
-
#element_validator ⇒ Object
readonly
Returns the value of attribute element_validator.
Instance Method Summary collapse
- #===(value) ⇒ Boolean
-
#initialize(element_validator) ⇒ ArrayOf
constructor
A new instance of ArrayOf.
Constructor Details
#initialize(element_validator) ⇒ ArrayOf
Returns a new instance of ArrayOf.
358 359 360 361 |
# File 'lib/value_semantics.rb', line 358 def initialize(element_validator) @element_validator = element_validator freeze end |
Instance Attribute Details
#element_validator ⇒ Object (readonly)
Returns the value of attribute element_validator.
356 357 358 |
# File 'lib/value_semantics.rb', line 356 def element_validator @element_validator end |
Instance Method Details
#===(value) ⇒ Boolean
364 365 366 |
# File 'lib/value_semantics.rb', line 364 def ===(value) Array === value && value.all? { |element| element_validator === element } end |