Class: Alert

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

Instance Method Summary collapse

Instance Method Details

#find_time_offObject



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

def find_time_off
  Timeoff.find_by_id(self.alert_type_id)
end

#get_shiftObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/alert.rb', line 7

def get_shift
  if self.alert_type == "Time Off"
      Timeoff.find_by_id(self.alert_type_id)
  elsif self.alert_type == "Cancellation"
      @cancellation = Cancellation.find_by_id(self.alert_type_id)
      if !@cancellation.nil?
        @cancellation.shift
      end 
  elsif self.alert_type == "Late Notice"
      @lateness = Lateness.find_by_id(self.alert_type_id)
      if !@lateness.nil?
        @lateness.shift
      end 
  elsif self.alert_type == "Swap"
     @swap = Swap.find_by_id(self.alert_type_id)
     if !@swap.nil? 
      @swap.shift
     end
  elsif self.alert_type =="unavailable"
     @unavailable = Unavailable.find_by_id(self.alert_type_id)
     if !@unavailable.nil? 
      @unavailable.shift
     end
  elsif self.alert_type =="Fill Shift"
    Shift.find_by_id(self.alert_type_id)   
  end
end

#get_shift_jobObject



35
36
37
38
39
40
# File 'app/models/alert.rb', line 35

def get_shift_job
  @swap = Swap.find_by_id(self.alert_type_id)
  if !@swap.nil? 
    @swap.shift.job.name
  end
end