Sha256: 2476bfb63aaee039beedf3f268f698d8bcb76db522e0af9ca21f0c0a9ccb332f
Contents?: true
Size: 816 Bytes
Versions: 4
Compression:
Stored size: 816 Bytes
Contents
module Marty module BackgroundJob module UpdateSchedule def self.call(id:, job_class:) model = Marty::BackgroundJob::Schedule.find_by(id: id) return remove_schedule(job_class: job_class) if model.blank? return remove_schedule(job_class: job_class) if model.off? return schedule(job_class: job_class) if model.on? end def self.remove_schedule(job_class:) klass = job_class.constantize klass.remove_schedule if klass.respond_to?(:remove_schedule) true rescue NameError false end def self.schedule(job_class:) klass = job_class.constantize return false unless klass.respond_to?(:schedule) klass.schedule true rescue NameError false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems