Class: AutomateEm::JobProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/automate-em/utilities.rb

Instance Method Summary collapse

Constructor Details

#initialize(jobs, index, lock) ⇒ JobProxy

Returns a new instance of JobProxy.



23
24
25
26
27
# File 'lib/automate-em/utilities.rb', line 23

def initialize(jobs, index, lock)
	@jobs = jobs
	@index = index
	@job = @jobs[@index]	# only ever called from within the lock
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)



42
43
44
45
46
# File 'lib/automate-em/utilities.rb', line 42

def method_missing(name, *args, &block)
	EM.schedule do
		@job.send(name, *args, &block)
	end
end

Instance Method Details

#unscheduleObject



30
31
32
33
34
35
36
37
38
# File 'lib/automate-em/utilities.rb', line 30

def unschedule
	EM.schedule do
		begin
			@job.unschedule
			@jobs.delete(@index)
		rescue
		end
	end
end