Class: JobTask

Inherits:
Object
  • Object
show all
Defined in:
lib/job.rb

Overview

Defines a type of task used by the Job class to execute code when a job is triggered.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ JobTask

Creates a type of task to run when triggered.

Takes a block which is executed when the JobTask#execute method is called.



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

def initialize(&block)
	@code = block.to_proc
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



15
16
17
# File 'lib/job.rb', line 15

def code
  @code
end

Instance Method Details

#executeObject

Executes the job created for this JobTask object.

Returns the value that the job exited with.



34
35
36
# File 'lib/job.rb', line 34

def execute
	return @code.call
end