| Module | OpenWFE::ParticipantMethods |
| In: |
lib/openwfe/engine/participant_methods.rb
|
The methods of the engine about participants (register, unregister, lookup, …)
Given a participant name, returns the participant in charge of handling workitems for that name. May be useful in some embedded contexts.
# File lib/openwfe/engine/participant_methods.rb, line 103
103: def get_participant (participant_name)
104:
105: get_participant_map.lookup_participant participant_name
106: end
Registers a participant in this [embedded] engine. This method is a shortcut to the ParticipantMap method with the same name.
engine.register_participant "user-.*", HashParticipant
or
engine.register_participant "user-.*" do |wi|
puts "participant '#{wi.participant_name}' received a workitem"
#
# and did nothing with it
# as a block participant implicitely returns the workitem
# to the engine
end
Returns the participant instance.
The participant parameter can be set to hash like in
engine.register_participant(
"alpha",
{ :participant => HashParticipant, :position => :first })
or
engine.register_participant("alpha", :position => :first) do
puts "first !"
end
There are some times where you have to position a participant first (especially with the regex technique).
see ParticipantMap#register_participant
# File lib/openwfe/engine/participant_methods.rb, line 84
84: def register_participant (regex, participant=nil, &block)
85:
86: #get_participant_map.register_participant(
87: # regex, participant, &block)
88:
89: params = if participant.class == Hash
90: participant
91: else
92: { :participant => participant }
93: end
94:
95: get_participant_map.register_participant regex, params, &block
96: end