Class: ForemanPatch::WindowPlan

Inherits:
ApplicationRecord
  • Object
show all
Includes:
ForemanTasks::Concerns::ActionSubject
Defined in:
app/models/foreman_patch/window_plan.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_byObject

Returns the value of attribute end_by.



5
6
7
# File 'app/models/foreman_patch/window_plan.rb', line 5

def end_by
  @end_by
end

#start_atObject

Returns the value of attribute start_at.



5
6
7
# File 'app/models/foreman_patch/window_plan.rb', line 5

def start_at
  @start_at
end

Instance Method Details

#start_timeObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/foreman_patch/window_plan.rb', line 27

def start_time
  value = read_attribute(:start_time)
  return nil if value.blank?

  if value.acts_like?(:time)
    args = [value.year, value.month, value.day, value.hour, value.min, value.sec]
    time = Time.find_zone(Setting[:patch_schedule_time_zone]).local(*args)
  else
    time = Time.find_zone(Setting[:patch_schedule_time_zone]).parse(value)
  end
  time.to_time
end

#start_time=(value) ⇒ Object



40
41
42
43
44
45
46
47
# File 'app/models/foreman_patch/window_plan.rb', line 40

def start_time=(value)
  if value.acts_like?(:time)
    time = value.in_time_zone(Setting[:patch_schedule_time_zone]).time
  else
    time = Time.find_zone(Setting[:patch_schedule_time_zone]).parse(value).time
  end
  write_attribute(:start_time, time)
end

#to_paramsObject



58
59
60
61
62
63
64
65
# File 'app/models/foreman_patch/window_plan.rb', line 58

def to_params
  {
    name: name,
    description: description,
    start_at: start_at,
    end_by: end_by,
  }
end