module SecondGuardianName
  extend ActiveSupport::Concern
  
  included do
    def guardian_2_name
      "#{guardian_2_first_name} #{guardian_2_last_name}".titleize
    end

    def guardian_2_name=(value)
      if value.include?(' ')
        split = value.split(" ", 2)
        self.guardian_2_first_name = split.first
        self.guardian_2_last_name = split.last
      else
        self.guardian_2_first_name = value
        self.guardian_2_last_name = "(Not Given)"
      end
    end
  end
end
