module PersonName
  extend ActiveSupport::Concern
  
  included do
    def person_name
      "#{person_first_name} #{person_last_name}".titleize
    end
  
    def person_name=(value)
      if value.include?(' ')
        split = value.split(" ", 2)
        self.person_first_name = split.first
        self.person_last_name = split.last
      else
        self.person_first_name = value
        self.person_last_name = "(Not Given)"
      end
    end
  end
end
