module EthnicityConcern
Constants
- ANY_OTHER_ETHNIC_BACKGROUNDS
- ETHNIC_BACKGROUNDS
- ETHNIC_BACKGROUNDS_BY_GROUP
- ETHNIC_GROUPS
Public Instance Methods
Source
# File app/models/concerns/ethnicity_concern.rb, line 94 def any_other_ethnic_backgrounds = ANY_OTHER_ETHNIC_BACKGROUNDS def ethnic_backgrounds_for_group(group) ethnic_backgrounds_by_group.fetch(group&.to_sym, nil) end end
Source
# File app/models/concerns/ethnicity_concern.rb, line 101 def assign_ethnicity_from!(source) self.ethnic_group = source.ethnic_group self.ethnic_background = source.ethnic_background self.ethnic_background_other = source.ethnic_background_other save! end
Source
# File app/models/concerns/ethnicity_concern.rb, line 126 def ethnic_background_requires_additional_details? return false if ethnic_background.blank? self.class.any_other_ethnic_backgrounds.include?(ethnic_background.to_sym) end
Source
# File app/models/concerns/ethnicity_concern.rb, line 93 def ethnic_backgrounds_by_group = ETHNIC_BACKGROUNDS_BY_GROUP def any_other_ethnic_backgrounds = ANY_OTHER_ETHNIC_BACKGROUNDS def ethnic_backgrounds_for_group(group) ethnic_backgrounds_by_group.fetch(group&.to_sym, nil) end end def assign_ethnicity_from!(source) self.ethnic_group = source.ethnic_group self.ethnic_background = source.ethnic_background self.ethnic_background_other = source.ethnic_background_other save! end def normalise_ethnic_background_other return if ethnic_background.blank? # If the chosen background isn't an "any other" option, this value must not persist self.ethnic_background_other = nil unless ethnic_background_requires_additional_details? end def require_ethnic_background_other? validate_ethnic_background_other? && ethnic_background_requires_additional_details? end def validate_ethnic_background_other? will_save_change_to_ethnic_background? || will_save_change_to_ethnic_background_other? end def ethnic_background_requires_additional_details? return false if ethnic_background.blank? self.class.any_other_ethnic_backgrounds.include?(ethnic_background.to_sym) end end
Source
# File app/models/concerns/ethnicity_concern.rb, line 92 def ethnic_backgrounds_enum = ETHNIC_BACKGROUNDS def ethnic_backgrounds_by_group = ETHNIC_BACKGROUNDS_BY_GROUP def any_other_ethnic_backgrounds = ANY_OTHER_ETHNIC_BACKGROUNDS def ethnic_backgrounds_for_group(group) ethnic_backgrounds_by_group.fetch(group&.to_sym, nil) end end def assign_ethnicity_from!(source) self.ethnic_group = source.ethnic_group self.ethnic_background = source.ethnic_background self.ethnic_background_other = source.ethnic_background_other save! end def normalise_ethnic_background_other return if ethnic_background.blank? # If the chosen background isn't an "any other" option, this value must not persist self.ethnic_background_other = nil unless ethnic_background_requires_additional_details? end def require_ethnic_background_other? validate_ethnic_background_other? && ethnic_background_requires_additional_details? end def validate_ethnic_background_other? will_save_change_to_ethnic_background? || will_save_change_to_ethnic_background_other? end def ethnic_background_requires_additional_details? return false if ethnic_background.blank? self.class.any_other_ethnic_backgrounds.include?(ethnic_background.to_sym) end
Source
# File app/models/concerns/ethnicity_concern.rb, line 96 def ethnic_backgrounds_for_group(group) ethnic_backgrounds_by_group.fetch(group&.to_sym, nil) end
Source
# File app/models/concerns/ethnicity_concern.rb, line 91 def ethnic_groups_enum = ETHNIC_GROUPS def ethnic_backgrounds_enum = ETHNIC_BACKGROUNDS def ethnic_backgrounds_by_group = ETHNIC_BACKGROUNDS_BY_GROUP def any_other_ethnic_backgrounds = ANY_OTHER_ETHNIC_BACKGROUNDS def ethnic_backgrounds_for_group(group) ethnic_backgrounds_by_group.fetch(group&.to_sym, nil) end end def assign_ethnicity_from!(source) self.ethnic_group = source.ethnic_group self.ethnic_background = source.ethnic_background self.ethnic_background_other = source.ethnic_background_other save! end def normalise_ethnic_background_other return if ethnic_background.blank? # If the chosen background isn't an "any other" option, this value must not persist self.ethnic_background_other = nil unless ethnic_background_requires_additional_details? end def require_ethnic_background_other? validate_ethnic_background_other? && ethnic_background_requires_additional_details? end def validate_ethnic_background_other? will_save_change_to_ethnic_background? || will_save_change_to_ethnic_background_other? end def ethnic_background_requires_additional_details? return false if ethnic_background.blank? self.class.any_other_ethnic_backgrounds.include?(ethnic_background.to_sym)
Source
# File app/models/concerns/ethnicity_concern.rb, line 108 def normalise_ethnic_background_other return if ethnic_background.blank? # If the chosen background isn't an "any other" option, this value must not persist self.ethnic_background_other = nil unless ethnic_background_requires_additional_details? end
Source
# File app/models/concerns/ethnicity_concern.rb, line 116 def require_ethnic_background_other? validate_ethnic_background_other? && ethnic_background_requires_additional_details? end
Source
# File app/models/concerns/ethnicity_concern.rb, line 121 def validate_ethnic_background_other? will_save_change_to_ethnic_background? || will_save_change_to_ethnic_background_other? end