Class: Job

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
PeopleInACollection
Defined in:
app/models/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PeopleInACollection

#added_people, #detect_if_list_changed, #map_member_strings_to_users, #remove_empty_fields, #removed_people, #update_collection_members, #validate_members

Instance Attribute Details

#employees_overrideObject

Returns the value of attribute employees_override


28
29
30
# File 'app/models/job.rb', line 28

def employees_override
  @employees_override
end

#supervisors_overrideObject

When assigning faculty to a job, the user types in a series of strings that then need to be processed :job_supervisors_override is a temporary variable that is used to do validation of the strings (to verify that they are people in the system) and then to save the people in the job_supervisors association.


27
28
29
# File 'app/models/job.rb', line 27

def supervisors_override
  @supervisors_override
end

Instance Method Details

#notify_people(added_users, removed_users) ⇒ Object


48
49
50
51
52
53
# File 'app/models/job.rb', line 48

def notify_people added_users, removed_users
  update_log(added_users, removed_users)
  JobMailer.notify_hr(self, added_users, removed_users)
  JobMailer.notify_added_employees(self, added_users)
  JobMailer.notify_removed_employees(self, removed_users)
end

#update_log(added_users, removed_users) ⇒ Object


55
56
57
58
59
60
61
62
63
# File 'app/models/job.rb', line 55

def update_log added_users, removed_users
  self.log = "" if self.log.nil?
  if added_users.present?
    added_users.each { |user| self.log += Time.now.to_s + " - added " + user.human_name + "<br/>" }
  end
  if removed_users.present?
    removed_users.each { |user| self.log += Time.now.to_s + " - removed " + user.human_name + "<br/>" }
  end
end

#update_supervisors_and_employeesObject


43
44
45
46
# File 'app/models/job.rb', line 43

def update_supervisors_and_employees
  update_collection_members :supervisors_override, :supervisors, :update_log
  update_collection_members :employees_override, :employees, :notify_people
end

#validate_supervisors_and_employeesObject


38
39
40
41
# File 'app/models/job.rb', line 38

def validate_supervisors_and_employees
  validate_members :supervisors_override
  validate_members :employees_override
end