Skip to content

Commit

Permalink
[B] Improve handling of lowercase names
Browse files Browse the repository at this point in the history
  • Loading branch information
zdavis committed Apr 30, 2020
1 parent f77c62d commit 52fe8d1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/app/models/concerns/with_parsed_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module WithParsedName
# rubocop:disable Rails/ReadWriteAttribute
def name=(name)
parts = Namae::Name.parse(name).to_h.compact
validate_parts!(parts)
parts.each do |key, value|
next unless respond_to? KEY_MAP[key]

Expand Down Expand Up @@ -52,6 +53,15 @@ def full_name

private

def validate_parts!(parts)
# rubocop:disable Style/GuardClause
if parts[:particle].present? && parts[:given].blank?
parts[:given] = parts[:particle]
parts[:particle] = nil
end
# rubocop:enable Style/GuardClause
end

def nickname_not_blank!
return unless respond_to? :nickname

Expand Down

0 comments on commit 52fe8d1

Please sign in to comment.