def receive_last
indexes = @node['rets']
.each_with_index
.inject({ array: [], object: [], other: [] }) { |is, (e, i)|
case e
when Array then is[:array]
when Hash then is[:object]
else is[:other]
end << i
is }
a0 = indexes[:array].first || @node['rets'].length
o0 = indexes[:object].first || @node['rets'].length
kln = a0 < o0 ? :array : :object
okln = kln == :array ? :object : :array
cols = indexes[kln].collect { |i| @node['rets'][i] }
cols.unshift(node_payload_ret) \
if cols.length == 1 && Flor.type(node_payload_ret) == kln
fail Flor::FlorError.new('found no array or object to merge', self) \
if cols.empty?
unless att('lax', 'loose') == true || att('strict') == false
others = (indexes[:other] + indexes[okln]).sort
fail Flor::FlorError.new(
"found a non-#{kln} item (#{Flor.type(@node['rets'][others[0]])} item)",
self
) if others.any?
end
wrap('ret' => send(kln == :array ? :merge_arrays : :merge_objects, cols))
end