lib/pupa/models/concerns/nameable.rb in pupa-0.0.10 vs lib/pupa/models/concerns/nameable.rb in pupa-0.0.11

- old
+ new

@@ -3,19 +3,26 @@ # Adds the Popolo `other_names` property to a model. module Nameable extend ActiveSupport::Concern included do - attr_accessor :other_names + attr_reader :other_names dump :other_names end def initialize(*args) @other_names = [] super end + # Sets the other names. + # + # @param [Array] other_names a list of other names + def other_names=(other_names) + @other_names = symbolize_keys(other_names) + end + # Adds an alternate or former name. # # @param [String] name an alternate or former name # @param [Date,Time] start_date the date on which the name was adopted # @param [Date,Time] end_date the date on which the name was abandoned @@ -29,10 +36,10 @@ data[:end_date] = end_date end if note data[:note] = note end - if name + if name.present? @other_names << data end end end end