Class OpenWFE::DefinedExpression
In: lib/openwfe/expressions/fe_equals.rb
Parent: FlowExpression

This expression class actually implements ‘defined’ and ‘undefined’.

They are some kind of ‘equals’ for validating the presence or not of a variable or a workitem field (attribute).

    <if>
        <defined field="customer">
        <!-- then -->
        <subprocess ref="call_customer" />
    </if>

Since OpenWFEru 0.9.17, ‘defined’ and ‘undefined’ can be easily replaced by the "is [not ]set" suffix in the dollar notation :

    <if test="${f:customer_name} is set">
        <!-- then -->
        <subprocess ref="call_customer" />
    </if>

Methods

Included Modules

LookupMixin

Public Instance methods

[Source]

     # File lib/openwfe/expressions/fe_equals.rb, line 251
251:         def apply (workitem)
252: 
253:             fname = lookup_field(workitem, 'value') || lookup_field(workitem)
254: 
255:             fmatch = lookup_string_attribute(:field_match, workitem)
256: 
257:             vname = lookup_var(workitem, 'value') || lookup_var(workitem)
258: 
259:             result = if fname
260:                 workitem.has_attribute?(fname)
261:             elsif vname
262:                 lookup_variable(vname) != nil
263:             elsif fmatch
264:                 field_match?(workitem, fmatch)
265:             else
266:                 false # when in doubt, say 'no' (even when 'undefined' ?)
267:             end
268: 
269:             result = ( ! result) \
270:                 if result != nil and fei.expression_name == 'undefined'
271: 
272:             workitem.set_result result
273: 
274:             reply_to_parent workitem
275:         end

Protected Instance methods

[Source]

     # File lib/openwfe/expressions/fe_equals.rb, line 279
279:             def field_match? (workitem, regex)
280: 
281:                 workitem.attributes.each do |k, v|
282: 
283:                     return true if k.match(regex)
284:                 end
285: 
286:                 false
287:             end

[Validate]