Class: ForemanPatch::Window

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

Defined Under Namespace

Classes: Jail

Instance Method Summary collapse

Instance Method Details

#cancel(force = false) ⇒ Object



80
81
82
83
# File 'app/models/foreman_patch/window.rb', line 80

def cancel(force = false)
  method = force ? :abort : :cancel
  task.send(method) unless task.blank?
end

#durationObject



47
48
49
# File 'app/models/foreman_patch/window.rb', line 47

def duration
  end_by - start_at
end

#duration=(duration) ⇒ Object



51
52
53
# File 'app/models/foreman_patch/window.rb', line 51

def duration=(duration)
  self.end_by = start_at + duration
end

#move_by(duration) ⇒ Object



61
62
63
64
# File 'app/models/foreman_patch/window.rb', line 61

def move_by(duration)
  self.start_at = self.start_at + duration
  self.end_by = self.end_by + duration
end

#move_to(time) ⇒ Object



55
56
57
58
59
# File 'app/models/foreman_patch/window.rb', line 55

def move_to(time)
  span = duration
  self.start_at = time
  self.end_by = time + span
end

#published?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'app/models/foreman_patch/window.rb', line 85

def published?
  not ticket_id.blank?
end

#scheduleObject



74
75
76
77
78
# File 'app/models/foreman_patch/window.rb', line 74

def schedule
  User.as_anonymous_admin do
    ::ForemanTasks.delay(::Actions::ForemanPatch::Window::Patch, delay_options, self) unless scheduled?
  end
end

#scheduled?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'app/models/foreman_patch/window.rb', line 70

def scheduled?
  (not task.blank?) and task.scheduled?
end

#ticketObject



43
44
45
# File 'app/models/foreman_patch/window.rb', line 43

def ticket
  @ticket ||= Ticket.get(self)
end