Class: Lighthouse::LettersGenerator::VeteranSponsorResolver
- Inherits:
-
Object
- Object
- Lighthouse::LettersGenerator::VeteranSponsorResolver
- Defined in:
- lib/lighthouse/letters_generator/veteran_sponsor_resolver.rb
Class Method Summary collapse
- .dependent?(user) ⇒ Boolean
- .get_sponsor_for(user) ⇒ Object private
-
.get_sponsor_icn(user) ⇒ Object
Returns the Veteran sponsor’s ICN if user is a dependent, or nil if the user is not a depdendent In this relationship, the related Veteran is also called “sponsor” or “headOfFamily”.
Class Method Details
.dependent?(user) ⇒ Boolean
18 19 20 |
# File 'lib/lighthouse/letters_generator/veteran_sponsor_resolver.rb', line 18 def self.dependent?(user) user.person_types&.include?('DEP') end |
.get_sponsor_for(user) ⇒ Object (private)
22 23 24 25 26 27 |
# File 'lib/lighthouse/letters_generator/veteran_sponsor_resolver.rb', line 22 private_class_method def self.get_sponsor_for(user) veteran_relationships = user.relationships&.select(&:veteran_status) return unless veteran_relationships.presence veteran_relationships.first end |
.get_sponsor_icn(user) ⇒ Object
Returns the Veteran sponsor’s ICN if user is a dependent, or nil if the user is not a depdendent In this relationship, the related Veteran is also called “sponsor” or “headOfFamily”
10 11 12 13 14 15 16 |
# File 'lib/lighthouse/letters_generator/veteran_sponsor_resolver.rb', line 10 def self.get_sponsor_icn(user) if dependent? user sponsor = get_sponsor_for user sponsor.icn end end |