Parent

Included Modules

Class/Module Index [+]

Quicksearch

Ruote::BlockParticipant

One of the simplest participants. Simply passes a workitem to a block of ruby code.

engine.register_participant :alpha do |workitem|
  workitem.fields['time'] = Time.now
end

This participant implicitely replies to the engine when the block execution is over.

You can pass the flow_expression (participant expression) as well.

engine.register_participant :alpha do |workitem, flow_exp|
  workitem.fields['amount'] = flow_exp.lookup_variable('amount')
end

do_not_thread

By default, this participant (like most other participants) is executed in its own thread (in a Ruby runtime where EventMachine is running, EM.next_tick is used instead of a new thread).

You can change that behaviour (beware block thats monopolises the whole engine !) by doing

alpha = engine.register_participant :alpha do |workitem|
  workitem.fields['time'] = Time.now
end

alpha.do_not_thread = true

(you could also override do_not_thread, the method ...)

Attributes

context[RW]
do_not_thread[RW]

Public Class Methods

new(block, opts) click to toggle source
# File lib/ruote/part/block_participant.rb, line 72
def initialize (block, opts)

  @opts = opts
  @block = block
  @do_not_thread = false
end

Public Instance Methods

cancel(fei, flavour) click to toggle source
# File lib/ruote/part/block_participant.rb, line 98
def cancel (fei, flavour)

  # do nothing
end
consume(workitem) click to toggle source
# File lib/ruote/part/block_participant.rb, line 79
def consume (workitem)

  r = if @block.arity == 1

    @block.call(workitem)
  else

    @block.call(
      workitem, Ruote::Exp::FlowExpression.fetch(@context, workitem.h.fei))
  end

  if r != nil && r != workitem
    #workitem.result = r
    workitem.result = (Rufus::Json.dup(r) rescue nil)
  end

  reply_to_engine(workitem)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.