Don't use a for-loop (each
), that's how you'd do it in language like C, in Ruby we have handy functional abstractions (or can build them if not present) like Enumerable#any?:
receive_payment_on = config[:sections].any? do |section|
if section[:applicants]
section[:applicants][:sections].any? do |app_sec|
app_sec[:employment] && app_sec[:employment][:receive_payment_on]
end
end
end