lib/openwfe/participants/participant.rb in openwferu-0.9.10.653 vs lib/openwfe/participants/participant.rb in openwferu-0.9.11

- old
+ new

@@ -63,15 +63,16 @@ raise NotImplementedError.new( "implementation for method consume() "+ "is missing in class '#{self.class}'") end - # + #-- # (optional) # #def cancel (cancelitem) #end + #++ end # # Local participants provide handy methods like reply_to_engine() to # further implementations of the Participant concept. @@ -86,11 +87,36 @@ # def get_flow_expression (workitem) return nil if not @application_context - @application_context[S_EXPRESSION_POOL]\ - .fetch_expression(workitem.flow_expression_id) + get_expression_pool.fetch_expression(workitem.flow_expression_id) + end + + # + # A convenience method for calling block passed to participants + # for templates (mail participants) or execution (BlockParticipant). + # + # Allows for such blocks : + # + # { |workitem| ... } + # { |participant_expression, workitem| ... } + # { |participant_expression, participant, workitem| ... } + # + # For 0 or more than 3 arguments, the block will be called without + # arguments. + # + def call_block (block, workitem) + + if block.arity == 1 + block.call workitem + elsif block.arity == 2 + block.call get_flow_expression(workitem), workitem + elsif block.arity == 3 + block.call get_flow_expression(workitem), self, workitem + else + block.call + end end # # Participants use this method to reply to their engine when # their job is done.