Class: NextSgad::Employee

Inherits:
ApplicationRecord show all
Defined in:
app/models/next_sgad/employee.rb

Constant Summary collapse

INITIAL_LETTER =
"E"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#create_number, #create_number!

Class Method Details

.can_be_assessedObject



53
54
55
# File 'app/models/next_sgad/employee.rb', line 53

def self.can_be_assessed
  where(can_be_assessed: true)
end

.cannot_be_assessedObject



57
58
59
# File 'app/models/next_sgad/employee.rb', line 57

def self.cannot_be_assessed
  where(can_be_assessed: false)
end

.map_for_filterObject



37
38
39
# File 'app/models/next_sgad/employee.rb', line 37

def self.map_for_filter
  [[I18n.t(:everything), :all]] + all.map {|f| [f.name_and_number, f.id]}
end

.map_for_selectObject



33
34
35
# File 'app/models/next_sgad/employee.rb', line 33

def self.map_for_select
  all.map {|f| [f.name_and_number, f.id]}
end

.map_level_for_filterObject



45
46
47
# File 'app/models/next_sgad/employee.rb', line 45

def self.map_level_for_filter
  [[I18n.t(:everything), :all]] + all.order(level: :asc).map {|f| [f.level, f.level]}.uniq
end

.map_paygrade_for_filterObject



41
42
43
# File 'app/models/next_sgad/employee.rb', line 41

def self.map_paygrade_for_filter
  [[I18n.t(:everything), :all]] + all.order(paygrade: :asc).map {|f| [f.paygrade, f.paygrade]}.uniq
end

Instance Method Details

#first_and_last_nameObject



21
22
23
# File 'app/models/next_sgad/employee.rb', line 21

def first_and_last_name
  "#{first_name} #{last_name}"
end

#full_abbr_nameObject



25
26
27
# File 'app/models/next_sgad/employee.rb', line 25

def full_abbr_name
  "#{first_name} #{middle_name.to_s.split(' ').map{|name| "#{name.first.upcase}." if name.present?}.compact.join(' ')} #{last_name}"
end

#full_nameObject



17
18
19
# File 'app/models/next_sgad/employee.rb', line 17

def full_name
  "#{first_name} #{middle_name} #{last_name}"
end

#is_assessed?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/models/next_sgad/employee.rb', line 61

def is_assessed?
  can_be_assessed
end

#is_not_assessed?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/models/next_sgad/employee.rb', line 65

def is_not_assessed?
  !is_assessed?
end

#name_and_numberObject



29
30
31
# File 'app/models/next_sgad/employee.rb', line 29

def name_and_number
  "#{number} - #{first_name} #{last_name}"
end

#unread_messagesObject



49
50
51
# File 'app/models/next_sgad/employee.rb', line 49

def unread_messages
  employee_messages.unread
end