module Dripper
Public Class Methods
included(klass)
click to toggle source
# File lib/dripper.rb, line 6 def self.included(klass) klass.extend ClassMethods end
new(instance)
click to toggle source
# File lib/dripper.rb, line 10 def initialize(instance) raise ArgumentError, "The object must respond to #id" unless instance.respond_to?(:id) raise ArgumentError, "The object must respond to #created_at" unless instance.respond_to?(:created_at) @instance = instance end
Public Instance Methods
enqueue(time)
click to toggle source
# File lib/dripper.rb, line 50 def enqueue(time) # nothing here end
offset_time(offset)
click to toggle source
# File lib/dripper.rb, line 20 def offset_time(offset) calculated_time = starting_time + offset options = self.class.send_at_options unless options[:weekends] if calculated_time.wday == 6 # Saturday calculated_time = calculated_time - 1.day elsif calculated_time.wday == 0 # Sunday calculated_time = calculated_time + 1.day end end calculated_time end
schedule!()
click to toggle source
# File lib/dripper.rb, line 44 def schedule! scheduled_times.each do |time| enqueue(time) end end
scheduled_times()
click to toggle source
# File lib/dripper.rb, line 33 def scheduled_times offset = self.class.send_at_offset self.class.after_blocks.map do |b| t = offset_time(b[:offset]) if offset and b[:offset] >= 1.day t = t.beginning_of_day + offset[0].hours + offset[1].minutes end t end end
starting_time()
click to toggle source
# File lib/dripper.rb, line 16 def starting_time @instance.created_at # Fix this end