Class: Peoplefinder::Person

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
Concerns::Authentication, Concerns::Completion, Concerns::Notifications, Concerns::Searchable, Concerns::WorkDays
Defined in:
app/models/peoplefinder/person.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#crop_hObject

Returns the value of attribute crop_h.



16
17
18
# File 'app/models/peoplefinder/person.rb', line 16

def crop_h
  @crop_h
end

#crop_wObject

Returns the value of attribute crop_w.



16
17
18
# File 'app/models/peoplefinder/person.rb', line 16

def crop_w
  @crop_w
end

#crop_xObject

Returns the value of attribute crop_x.



16
17
18
# File 'app/models/peoplefinder/person.rb', line 16

def crop_x
  @crop_x
end

#crop_yObject

Returns the value of attribute crop_y.



16
17
18
# File 'app/models/peoplefinder/person.rb', line 16

def crop_y
  @crop_y
end

#role_namesObject

Returns the value of attribute role_names.



16
17
18
# File 'app/models/peoplefinder/person.rb', line 16

def role_names
  @role_names
end

Class Method Details

.namesakes(person) ⇒ Object



32
33
34
35
36
# File 'app/models/peoplefinder/person.rb', line 32

def self.namesakes(person)
  where(surname: person.surname).
  where(given_name: person.given_name).
  where.not(id: person.id)
end

Instance Method Details

#nameObject



38
39
40
# File 'app/models/peoplefinder/person.rb', line 38

def name
  [given_name, surname].compact.join(' ').strip
end

#path(hint_group = nil) ⇒ Object



58
59
60
# File 'app/models/peoplefinder/person.rb', line 58

def path(hint_group = nil)
  group_path(hint_group) + [self]
end

#phoneObject



62
63
64
65
# File 'app/models/peoplefinder/person.rb', line 62

def phone
  return primary_phone_number if primary_phone_number.present?
  return secondary_phone_number if secondary_phone_number.present?
end

#role_and_groupObject



54
55
56
# File 'app/models/peoplefinder/person.rb', line 54

def role_and_group
  memberships.map { |m| [m.group_name, m.role].join(', ') }.join('; ')
end

#slug_sourceObject



46
47
48
49
50
51
52
# File 'app/models/peoplefinder/person.rb', line 46

def slug_source
  if email.present?
    email.split(/@/).first
  else
    name
  end
end

#support_emailObject



67
68
69
70
71
72
73
# File 'app/models/peoplefinder/person.rb', line 67

def support_email
  if groups.present?
    groups.first.team_email_address
  else
    Rails.configuration.support_email
  end
end

#to_sObject



42
43
44
# File 'app/models/peoplefinder/person.rb', line 42

def to_s
  name
end