Class: JobWorkflow::TaskCallable

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

Defined Under Namespace

Classes: AlreadyCalledError, NotCalledError

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ TaskCallable

: () { () -> void } -> void



20
21
22
23
# File 'lib/job_workflow/task_callable.rb', line 20

def initialize(&block)
  @block = block #: () -> void
  @called = false #: bool
end

Instance Method Details

#callObject

: () -> void

Raises:



26
27
28
29
30
31
# File 'lib/job_workflow/task_callable.rb', line 26

def call
  raise AlreadyCalledError if called

  self.called = true
  block.call
end

#called?Boolean

: () -> bool

Returns:

  • (Boolean)


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

def called?
  called
end