Class: Charming::Tasks::Task

Inherits:
Data
  • Object
show all
Defined in:
lib/charming/tasks/task.rb

Overview

Task is the unit of work submitted to a task executor. It pairs a name (used by ‘on_task` handlers to route the result) with a block to invoke on the executor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



7
8
9
# File 'lib/charming/tasks/task.rb', line 7

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/charming/tasks/task.rb', line 7

def name
  @name
end

Instance Method Details

#callObject

Invokes the task’s block in the executor’s thread and returns its value (or raises).



9
# File 'lib/charming/tasks/task.rb', line 9

def call = block.call