Class: Ressbo::Person

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/ressbo/models/person.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_address_book(person) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ressbo/models/person.rb', line 34

def self.from_address_book (person)
  record = new
  
  if person.company?
    record.first_name = person.organization
    record.company = true
  else
    record.first_name = person.first_name
    record.last_name  = person.last_name
  end
  
  person.emails.each do |email|
    record.emails << Email.from_address_book(email)
  end
  
  record.save!
  record
end

Instance Method Details

#nameObject



54
55
56
# File 'lib/ressbo/models/person.rb', line 54

def name
  [first_name, last_name].compact.join(' ')
end