Class: Person

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

Direct Known Subclasses

Company, Customer, Employee

Constant Summary collapse

MALE =

sex enumeration

1
FEMALE =
2

Instance Method Summary collapse

Constructor Details

#initialize(attributes = nil, options = {}) ⇒ Person

Constructor



38
39
40
41
42
43
# File 'app/models/person.rb', line 38

def initialize(attributes = nil, options = {})
  super

  build_vcard unless vcard
  vcard.build_address unless vcard.address
end

Instance Method Details

#to_s(format = :default) ⇒ Object

String



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/person.rb', line 11

def to_s(format = :default)
  return unless vcard

  s = vcard.full_name

  case format
    when :long
      s += " (#{vcard.locality})" if vcard.locality
  end

  return s
end