Class: ForemanPatch::Window
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ForemanPatch::Window
- Includes:
- ForemanTasks::Concerns::ActionSubject
- Defined in:
- app/models/foreman_patch/window.rb
Defined Under Namespace
Classes: Jail
Instance Method Summary collapse
- #cancel(force = false) ⇒ Object
- #duration ⇒ Object
- #duration=(duration) ⇒ Object
- #move_by(duration) ⇒ Object
- #move_to(time) ⇒ Object
- #published? ⇒ Boolean
- #schedule ⇒ Object
- #scheduled? ⇒ Boolean
- #ticket ⇒ Object
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 |
#duration ⇒ Object
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
85 86 87 |
# File 'app/models/foreman_patch/window.rb', line 85 def published? not ticket_id.blank? end |
#schedule ⇒ Object
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, , self) unless scheduled? end end |
#scheduled? ⇒ Boolean
70 71 72 |
# File 'app/models/foreman_patch/window.rb', line 70 def scheduled? (not task.blank?) and task.scheduled? end |