Class: Strict::Validators::ArrayOf

Inherits:
Object
  • Object
show all
Defined in:
lib/strict/validators/array_of.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element_validator) ⇒ ArrayOf

Returns a new instance of ArrayOf.



8
9
10
# File 'lib/strict/validators/array_of.rb', line 8

def initialize(element_validator)
  @element_validator = element_validator
end

Instance Attribute Details

#element_validatorObject (readonly)

Returns the value of attribute element_validator.



6
7
8
# File 'lib/strict/validators/array_of.rb', line 6

def element_validator
  @element_validator
end

Instance Method Details

#===(value) ⇒ Object



12
13
14
15
16
# File 'lib/strict/validators/array_of.rb', line 12

def ===(value)
  Array === value && value.all? do |v|
    element_validator === v
  end
end

#inspectObject Also known as: to_s



18
19
20
# File 'lib/strict/validators/array_of.rb', line 18

def inspect
  "ArrayOf(#{element_validator.inspect})"
end