| Class | OpenWFE::FileParticipant |
| In: |
lib/openwfe/participants/participants.rb
|
| Parent: | Object |
Just dumps the incoming workitem in a file as a YAML String.
By default, this participant will not reply to the engine once the workitem got dumped to its file, but you can set its reply_anyway field to true to make it reply anyway…
| reply_anyway | [RW] | |
| workdir | [RW] |
The constructor expects as a unique optional param either the application_context either the ‘output’ dir for the participant.
# File lib/openwfe/participants/participants.rb, line 68
68: def initialize (context_or_dir=nil)
69:
70: @workdir = get_work_directory(context_or_dir) + "/out/"
71:
72: @reply_anyway = false
73: end
The method called by the engine for each incoming workitem.
# File lib/openwfe/participants/participants.rb, line 78
78: def consume (workitem)
79:
80: FileUtils.makedirs(@workdir) unless File.exist?(@workdir)
81:
82: file_name = @workdir + determine_file_name(workitem)
83:
84: dump_to_file(file_name, workitem)
85:
86: reply_to_engine(workitem) if @reply_anyway
87: end
You can override this method to control into which file (name) each workitem gets dumped. You could even have a unique file for all workitems transiting through this participant.
# File lib/openwfe/participants/participants.rb, line 107
107: def determine_file_name (workitem)
108:
109: fei = workitem.fei
110:
111: OpenWFE::ensure_for_filename(
112: "#{fei.wfid}_#{fei.expression_id}__" +
113: "#{fei.workflow_definition_name}__" +
114: "#{fei.workflow_definition_revision}" +
115: "#{workitem.participant_name}.yaml")
116: end
This method does the actual job of dumping the workitem (as some YAML to a file). It can be easily overriden.
# File lib/openwfe/participants/participants.rb, line 94
94: def dump_to_file (file_name, workitem)
95:
96: File.open(file_name, "w") do |file|
97: file.print encode_workitem(workitem)
98: end
99: end