Created — forked from terrbear/scheduledjob.rb

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View scheduledjob.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
module Jobs
module ScheduledJob
def self.included(base)
base.extend(ClassMethods)
end
def perform_with_schedule
Delayed::Job.enqueue self, 0, self.class.schedule.from_now.getutc
perform_without_schedule
end
 
module ClassMethods
def method_added(name)
if name.to_s == "perform" && !@redefined
@redefined = true
alias_method_chain :perform, :schedule
end
end
def schedule
@schedule
end
def run_every(time)
@schedule = time
end
end
 
end
end
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.