Module: IronCuke::ScheduledQueue

Included in:
IronCuke
Defined in:
lib/iron_cuke/scheduled_queue.rb

Instance Method Summary collapse

Instance Method Details

#cancel_schedule(scheduled_task_id) ⇒ Object



20
21
22
# File 'lib/iron_cuke/scheduled_queue.rb', line 20

def cancel_schedule(scheduled_task_id)
	scheduled_queue.each { |k,v| v.delete_if{ |data| data.id == scheduled_task_id  } }
end

#clear_schedulesObject



24
25
26
# File 'lib/iron_cuke/scheduled_queue.rb', line 24

def clear_schedules
	scheduled_queue.clear
end

#schedule(worker, schedule_options) ⇒ Object

Raises:

  • (NotImplementedError)


10
11
12
13
14
15
16
17
18
# File 'lib/iron_cuke/scheduled_queue.rb', line 10

def schedule(worker, schedule_options)
	raise NotImplementedError if schedule_options[:run_times] > 1

	scheduled_queue[schedule_options[:start_at]] ||= []
	item = IronCuke::QueueItem.new(worker, schedule_options)
	scheduled_queue[schedule_options[:start_at]] << item
	worker.schedule_id = item.id
	response = IronCuke::ScheduledQueue.create_response(item)
end

#schedulesObject



6
7
8
# File 'lib/iron_cuke/scheduled_queue.rb', line 6

def schedules
	scheduled_queue.values.map { |scheduled| scheduled.map { |data| data.worker } }.flatten
end