Method: Fend::Plugins::Core::ParamMethods#each
- Defined in:
- lib/fend.rb
#each(opts = {}, &block) ⇒ Object
Define enumerable param member and execute validation block
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/fend.rb', line 204 def each(opts = {}, &block) return if (flat? && invalid?) || !@value.is_a?(Enumerable) is_hash = opts[:hash].eql?(true) return if is_hash && !@value.is_a?(Hash) @value.each_with_index do |value, index| param_name, param_value = is_hash ? value : [index, value] param = _build_param(param_name, param_value) yield(param, index) _nest_errors(param.name, param.errors) if param.invalid? end end |