lib/openwfe/participants/participants.rb in openwferu-0.9.10.653 vs lib/openwfe/participants/participants.rb in openwferu-0.9.11
- old
+ new
@@ -66,18 +66,10 @@
# The constructor expects as a unique optional param either the
# application_context either the 'output' dir for the participant.
#
def initialize (context_or_dir=nil)
- #if context_or_dir.kind_of? Hash
- # @application_context = context_or_dir
- # @workdir = @application_context[:work_directory]
- #else
- # @workdir = context_or_dir
- #end
- #@workdir = OpenWFE::DEFAULT_WORK_DIRECTORY unless @workdir
- #@workdir = "#{@workdir}/out/"
@workdir = OpenWFE::get_work_directory(context_or_dir) + "/out/"
@reply_anyway = false
end
@@ -175,25 +167,45 @@
unless @block
end
def consume (workitem)
- result = if @block.arity == 1
- @block.call workitem
- elsif @block.arity > 1
- @block.call get_flow_expression(workitem), workitem
- else
- @block.call
- end
+ result = call_block @block, workitem
- if result
- #ldebug { "consume() result is of class #{result.class.name}" }
- workitem.set_result(result)
- end
+ workitem.set_result(result) if result
reply_to_engine(workitem) \
if workitem.kind_of? InFlowWorkItem
# else it's a cancel item
+ end
+ end
+
+ #
+ # The NullParticipant never replies, it simply discards the workitems
+ # it receives.
+ #
+ class NullParticipant
+ include LocalParticipant
+
+ #
+ # Simply discards the incoming workitem
+ #
+ def consume (workitem)
+ end
+ end
+
+ #
+ # The NoOperationParticipant immediately replies to the engine upon
+ # receiving a workitem.
+ #
+ class NoOperationParticipant
+ include LocalParticipant
+
+ #
+ # Simply discards the incoming workitem
+ #
+ def consume (workitem)
+ reply_to_engine workitem
end
end
#
# The PrintParticipant will just emit its name to the