
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
None | size: 0.57 KB | hits: 21 | expires: Never
#The following assumes an object named "obj" with an action named "meth" that you want to execute at a certain time.
#It is assumed that 'obj' has some notion of what weekday and time (hours and minutes) it needs to be executed.
#For the purposes of this example, it will be attached directly to obj., but could just as easily come from some associated object.
desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
current_time = Time.now
if obj.day == current_time.wday && obj.hour == current_time.hour
sleep(obj.min * 60)
obj.meth
end
end