Class OpenWFE::BlockParticipant
In: lib/openwfe/participants/participants.rb
Parent: Object

This participant is used by the register_participant() method of Engine class.

    engine.register_participant("the_boss") do |workitem|
        puts "the boss received a workitem"
    end

After the block executes, the BlockParticipant immediately replies to the engine.

You can pass a block with two arguments : flow_expression and workitem to BlockParticipant, it will automatically adapt.

    engine.register_participant("the_boss") do |fexp, wi|
        puts "the boss received a workitem from exp #{fexp.fei.to_s}"
    end

Having the FlowExpression instance at hand allows for advanced tricks, beware…

It‘s also OK to register a block participant without params :

    engine.register_participant :alice do
        puts "Alice received a workitem"
    end

Methods

consume   new  

Included Modules

LocalParticipant

Public Class methods

[Source]

     # File lib/openwfe/participants/participants.rb, line 159
159:         def initialize (block0=nil, &block1)
160:             @block = if block1
161:                 block1
162:             else
163:                 block0
164:             end
165:             raise "Missing a block parameter" \
166:                 unless @block
167:         end

Public Instance methods

[Source]

     # File lib/openwfe/participants/participants.rb, line 169
169:         def consume (workitem)
170: 
171:             result = call_block @block, workitem
172: 
173:             workitem.set_result(result) \
174:                 if result and result != workitem
175: 
176:             reply_to_engine(workitem) \
177:                 if workitem.kind_of? InFlowWorkItem
178:             # else it's a cancel ite
179:         end

[Validate]