Module: Moped::Executable

Included in:
Node
Defined in:
lib/moped/executable.rb

Overview

Provides common behavior around executing a thread local stack safely.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#execute(name) ⇒ Object

Given the name of a thread local stack, ensure that execution happens by starting and ending the stack execution cleanly.

Examples:

Ensure execution of a pipeline.

execute(:pipeline) do
  yield(self)
end

Parameters:

  • name (Symbol)

    The name of the stack.

Returns:

  • (Object)

    The result of the yield.

Since:

  • 2.0.0



22
23
24
25
26
27
28
29
# File 'lib/moped/executable.rb', line 22

def execute(name)
  begin_execution(name)
  begin
    yield(self)
  ensure
    end_execution(name)
  end
end

#executing?(name) ⇒ true, false

Are we currently executing a stack on the thread?

Examples:

Are we executing a pipeline?

executing?(:pipeline)

Parameters:

  • name (Symbol)

    The name of the stack.

Returns:

  • (true, false)

    If we are executing the stack.

Since:

  • 2.0.0



41
42
43
# File 'lib/moped/executable.rb', line 41

def executing?(name)
  !stack(name).empty?
end