From 88043a9386ba83777c1926c8f335063bad1cf1f1 Mon Sep 17 00:00:00 2001 From: magicmilo Date: Tue, 26 Oct 2021 14:39:26 +0100 Subject: [PATCH] made validator private method --- app/models/case_log.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 2a1e4d7d2..baab481af 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -55,13 +55,6 @@ class CaseLogValidator < ActiveModel::Validator end end - def women_of_child_bearing_age_in_household(record) - (1..8).any? do |n| - next if record["person_#{n}_gender"].nil? || record["person_#{n}_age"].nil? - record["person_#{n}_gender"] == "Female" && record["person_#{n}_age"] >= 16 && record["person_#{n}_age"] <= 50 - end - end - def validate(record) # If we've come from the form UI we only want to validate the specific fields # that have just been submitted. If we're submitting a log via API or Bulk Upload @@ -78,6 +71,15 @@ class CaseLogValidator < ActiveModel::Validator validation_methods.each { |meth| public_send(meth, record) } end end + + private + + def women_of_child_bearing_age_in_household(record) + (1..8).any? do |n| + next if record["person_#{n}_gender"].nil? || record["person_#{n}_age"].nil? + record["person_#{n}_gender"] == "Female" && record["person_#{n}_age"] >= 16 && record["person_#{n}_age"] <= 50 + end + end end class CaseLog < ApplicationRecord