lib/openwfe/workitem.rb in openwferu-0.9.7 vs lib/openwfe/workitem.rb in openwferu-0.9.8
- old
+ new
@@ -48,10 +48,16 @@
module OpenWFE
#
+ # The convention for the result of some expressions is to store
+ # their result in a workitem field named "__result__".
+ #
+ FIELD_RESULT = "__result__"
+
+ #
# WORKITEMS
#
#
# The base class for all the workitems.
@@ -277,9 +283,41 @@
wi = super
wi.dispatch_time = h[:dispatch_time]
wi.history = h[:history]
wi.filter = h[:filter]
wi
+ end
+
+ #
+ # Sets the '__result__' field of this workitem
+ #
+ def set_result (result)
+ @attributes[FIELD_RESULT] = result
+ end
+
+ #
+ # Makes sure the '__result__' field of this workitem is empty.
+ #
+ def unset_result
+ @attributes.delete FIELD_RESULT
+ end
+
+ #
+ # Just a shortcut (for consistency) of
+ #
+ # workitem.attributes["__result__"]
+ #
+ def get_result
+ @attributes[FIELD_RESULT]
+ end
+
+ #
+ # Returns true or false.
+ #
+ def get_boolean_result
+ r = get_result
+ return false unless r
+ return (r == true or r == "true")
end
end
#
# When it needs to cancel a branch of a process instance, the engine