lib/openwfe/expressions/fe_if.rb in openwferu-0.9.15 vs lib/openwfe/expressions/fe_if.rb in openwferu-0.9.16

- old
+ new

@@ -97,21 +97,30 @@ class IfExpression < FlowExpression include ConditionMixin names :if - attr_accessor \ - :condition_replied + # + # This boolean is set to true when the conditional claused has + # been evaluated and the 'if' is waiting for the consequence's + # reply. + # + attr_accessor :condition_replied + def apply (workitem) - workitem.unset_result + #workitem.unset_result + # + # since OpenWFEru 0.9.16 previous __result__ values + # are not erased before an 'if'. test = eval_condition(:test, workitem, :not) if @children.length < 1 - workitem.set_result test if test + #workitem.set_result test if test + workitem.set_result((test != nil and test != false)) reply_to_parent(workitem) return end @condition_replied = (test != nil) @@ -127,25 +136,30 @@ end end def reply (workitem) - if @condition_replied - reply_to_parent(workitem) - return - end + return reply_to_parent(workitem) \ + if @condition_replied result = workitem.attributes[FIELD_RESULT] @condition_replied = true store_itself() apply_consequence result, workitem end + # + # This reply_to_parent takes care of cleaning all the children + # before replying to the parent expression, this is important + # because only the 'then' or the 'else' child got evaluated, the + # remaining one has to be cleaned out here. + # def reply_to_parent(workitem) + clean_children() super workitem end protected @@ -200,16 +214,27 @@ # class CaseExpression < FlowExpression names :case, :switch - attr_accessor \ - :offset, - :evaluating_condition + # + # keeping track of where we are in the case iteration + # + attr_accessor :offset + # + # set to 'true' when the case expression is actually evaluating + # a condition (ie not triggering a consequence). + # + attr_accessor :evaluating_condition + + def apply (workitem) - workitem.unset_result + #workitem.unset_result + # + # since OpenWFEru 0.9.16 previous __result__ values + # are not erased before a 'case'. @offset = nil trigger_child workitem, true end