Module: NoyoFulfillment::Mixins::HasPerson

Included in:
Dependent, Employee
Defined in:
lib/noyo_fulfillment/models/mixins/has_person.rb

Instance Method Summary collapse

Instance Method Details

#nameObject



21
22
23
24
25
26
# File 'lib/noyo_fulfillment/models/mixins/has_person.rb', line 21

def name
  return nil if person.nil?

  %w[first_name middle_name last_name].map{ |attr| person.send(attr) }
    .join(' ').squeeze(' ').strip
end

#person=(value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/noyo_fulfillment/models/mixins/has_person.rb', line 8

def person=(value)
  if value.is_a? NoyoFulfillment::Person
    @person = value
  else
    if value.is_a? Hash
      person_attrs = value.with_indifferent_access
    else
      person_attrs = value
    end
    @person = NoyoFulfillment::Person.new(person_attrs)
  end
end