Class: Ippon::Validate::ForEach
Overview
Instance Attribute Summary collapse
- #element_schema ⇒ Schema readonly
Instance Method Summary collapse
-
#initialize(element_schema) ⇒ ForEach
constructor
A new instance of ForEach.
-
#process(result) ⇒ Object
Implements the Schema#process interface.
Methods inherited from Schema
#&, #unhalt, #validate, #validate!, #|
Constructor Details
#initialize(element_schema) ⇒ ForEach
Returns a new instance of ForEach.
901 902 903 |
# File 'lib/ippon/validate.rb', line 901 def initialize(element_schema) @element_schema = element_schema end |
Instance Attribute Details
#element_schema ⇒ Schema (readonly)
899 900 901 |
# File 'lib/ippon/validate.rb', line 899 def element_schema @element_schema end |
Instance Method Details
#process(result) ⇒ Object
Implements the Schema#process interface.
906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'lib/ippon/validate.rb', line 906 def process(result) new_value = [] result.value.each_with_index.map do |element, idx| element_result = @element_schema.validate(element) new_value << element_result.value result.add_nested(idx, element_result) end result.value = new_value result end |