Class: JobTask
- Inherits:
-
Object
- Object
- JobTask
- 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
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#execute ⇒ Object
Executes the job created for this JobTask object.
-
#initialize(&block) ⇒ JobTask
constructor
Creates a type of task to run when triggered.
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
15 16 17 |
# File 'lib/job.rb', line 15 def code @code end |
Instance Method Details
#execute ⇒ Object
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 |