Module: Pupa::Concerns::Nameable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Organization, Person
- Defined in:
- lib/pupa/models/concerns/nameable.rb
Overview
Adds the Popolo other_names
property to a model.
Instance Method Summary collapse
-
#add_name(name, start_date: nil, end_date: nil, note: nil, family_name: nil, given_name: nil, additional_name: nil, honorific_prefix: nil, honorific_suffix: nil, patronymic_name: nil) ⇒ Object
Adds an alternate or former name.
- #initialize(*args) ⇒ Object
-
#other_names=(other_names) ⇒ Object
Sets the other names.
Instance Method Details
#add_name(name, start_date: nil, end_date: nil, note: nil, family_name: nil, given_name: nil, additional_name: nil, honorific_prefix: nil, honorific_suffix: nil, patronymic_name: nil) ⇒ Object
Adds an alternate or former name.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pupa/models/concerns/nameable.rb', line 36 def add_name(name, start_date: nil, end_date: nil, note: nil, family_name: nil, given_name: nil, additional_name: nil, honorific_prefix: nil, honorific_suffix: nil, patronymic_name: nil) data = {name: name} if start_date data[:start_date] = start_date end if end_date data[:end_date] = end_date end if note data[:note] = note end if family_name data[:family_name] = family_name end if given_name data[:given_name] = given_name end if additional_name data[:additional_name] = additional_name end if honorific_prefix data[:honorific_prefix] = honorific_prefix end if honorific_suffix data[:honorific_suffix] = honorific_suffix end if patronymic_name data[:patronymic_name] = patronymic_name end if name.present? @other_names << data end end |
#initialize(*args) ⇒ Object
12 13 14 15 |
# File 'lib/pupa/models/concerns/nameable.rb', line 12 def initialize(*args) @other_names = [] super end |
#other_names=(other_names) ⇒ Object
Sets the other names.
20 21 22 |
# File 'lib/pupa/models/concerns/nameable.rb', line 20 def other_names=(other_names) @other_names = symbolize_keys(other_names) end |