Module: OpenWFE::ConditionMixin

Overview

A ConditionMixin is a mixin for flow expressions like ‘if’ and ‘break’ for example. It allows for shorter notations like

<if test="${f:approved} == true"/>

or

_loop do
    participant :graphical_designer
    participant :business_analyst
    _break :if => "${f:approved}"
end

Instance Method Summary collapse

Instance Method Details

#determine_condition_attribute(attname) ⇒ Object

Returns nil if the cited attname (without or without ‘r’ prefix) is not present.

Attname may be a String or a Symbol, or an Array of String or Symbol instances.

Returns the Symbol the attribute if present.



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/openwfe/expressions/condition.rb', line 90

def determine_condition_attribute (attname)

    attname = [ attname ] unless attname.is_a?(Array)

    attname.each do |aname|
        aname = aname.intern if aname.is_a?(String)
        return aname if has_attribute(aname)
        return aname if has_attribute("r" + aname.to_s)
    end

    nil
end

#eval_condition(attname, workitem, nattname = nil) ⇒ Object

This is the method brought to expression classes including this mixin. Easy evaluation of a conditon expressed in an attribute.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/openwfe/expressions/condition.rb', line 66

def eval_condition (attname, workitem, nattname=nil)

    positive = nil
    negative = nil

    positive = do_eval_condition(attname, workitem)
    negative = do_eval_condition(nattname, workitem) if nattname

    negative = (not negative) if negative != nil

    return positive if positive != nil

    negative
end