Module: Marty::BackgroundJob::UpdateSchedule
- Defined in:
- app/services/marty/background_job/update_schedule.rb
Class Method Summary collapse
- .call(id:, job_class:) ⇒ Object
- .remove_schedule(job_class:) ⇒ Object
- .schedule(job_class:) ⇒ Object
Class Method Details
.call(id:, job_class:) ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/services/marty/background_job/update_schedule.rb', line 4 def self.call(id:, job_class:) model = Marty::BackgroundJob::Schedule.find_by(id: id) return remove_schedule(job_class: job_class) unless model.present? return remove_schedule(job_class: job_class) if model.off? return schedule(job_class: job_class) if model.on? end |
.remove_schedule(job_class:) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/services/marty/background_job/update_schedule.rb', line 12 def self.remove_schedule(job_class:) klass = job_class.constantize klass.remove_schedule if klass.respond_to?(:remove_schedule) true rescue NameError false end |
.schedule(job_class:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/services/marty/background_job/update_schedule.rb', line 21 def self.schedule(job_class:) klass = job_class.constantize return false unless klass.respond_to?(:schedule) klass.schedule true rescue NameError false end |