lib/openwfe/extras/participants/csvparticipants.rb in openwferu-extras-0.9.16 vs lib/openwfe/extras/participants/csvparticipants.rb in openwferu-extras-0.9.17
- old
+ new
@@ -1,8 +1,8 @@
#
#--
-# Copyright (c) 2007, John Mettraux, OpenWFE.org
+# Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
@@ -35,18 +35,18 @@
# "made in Japan"
#
# John Mettraux at openwfe.org
#
+#require 'rubygems'
+require 'rufus/decision' # gem 'rufus-decision'
+
require 'openwfe/utils'
require 'openwfe/util/dollar'
require 'openwfe/participants/participant'
-require 'openwfe/extras/util/csvtable'
-include OpenWFE
-
module OpenWFE
module Extras
#
# Using CSV files to transform workitems
@@ -88,12 +88,11 @@
# Note that the CsvParticipant constructor also accepts a block.
#
class CsvParticipant
include LocalParticipant
- attr_accessor \
- :csv_table
+ attr_accessor :csv_table
#
# Builds a new CsvParticipant instance, csv_data or the block
# may contain a File instance, a String or an Array of Array of
# String instances.
@@ -102,20 +101,25 @@
super()
csv_data = block.call if block
- @csv_table = CsvTable.new(csv_data)
+ @csv_table = Rufus::DecisionTable.new csv_data
end
#
# This is the method called by the engine (actually the
# ParticipantExpression) when handling a workitem to this participant.
#
def consume (workitem)
- fe = get_flow_expression(workitem)
- workitem = @csv_table.transform_wi(fe, workitem)
- reply_to_engine(workitem)
+
+ fe = get_flow_expression workitem
+
+ @csv_table.transform!(FlowDict.new(fe, workitem, 'f'))
+ #
+ # default_prefix set to 'f'
+
+ reply_to_engine workitem
end
end
end
end