Skip to content

Commit

Permalink
logic to use new subject limited field added and replace hard coded list
Browse files Browse the repository at this point in the history
  • Loading branch information
syed87 committed Sep 26, 2023
1 parent fe1154b commit e6b5936
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,31 @@ class Country < ApplicationRecord
YAML.load(File.read("lib/countries-in-european-economic-area.yaml"))

validates :code, inclusion: { in: CODES }

attribute :subject_limited, :boolean

def eligibility_route
if subject_limited
"expanded"
elsif eligibility_skip_questions
"reduced"
else
"standard"
end
end

def eligibility_route=(value)
subject_limited_will_change!
eligibility_skip_questions_will_change!
if value == "standard"
self.subject_limited = false
self.eligibility_skip_questions = false
elsif value == "reduced"
self.subject_limited = false
self.eligibility_skip_questions = true
elsif value == "expanded"
self.subject_limited = true
self.eligibility_skip_questions = false
end
end
end

0 comments on commit e6b5936

Please sign in to comment.