Class/Module Index [+]

Quicksearch

Ruote::Exp::IfExpression

Here are examples of the 'if' expression in use :

_if do
  equals :field_value => 'customer', :other_value => 'British Petroleum'
  participant :ref => 'Allister'
end

and :

_if :test => '${f:customer} == British Petroleum' do
  participant :ref => 'Allister'
end

An else clause is accepted :

_if do
  equals :field_value => 'customer', :other_value => 'British Petroleum'
  participant :ref => 'Allister'
  participant :ref => 'Bernardo'
end

or :

_if :test => '${f:customer} == British Petroleum' do
  participant :ref => 'Allister'
  participant :ref => 'Bernardo'
end

Note that any expression accepts an :if attribute :

participant :ref => 'Al', :if => '${f:customer} == British Petroleum'

shorter

It's ok to shortcircuit the _if expression like this :

_if '${f:customer.name} == Fred' do
  subprocess 'premium_course'
  subprocess 'regular_course'
end

Public Instance Methods

apply() click to toggle source
# File lib/ruote/exp/fe_if.rb, line 75
def apply

  reply(h.applied_workitem)
end
reply(workitem) click to toggle source

called by 'else', 'then' or perhaps 'equals'

# File lib/ruote/exp/fe_if.rb, line 82
def reply (workitem)

  if workitem['fei'] == h.fei # apply --> reply

    h.test = attribute(:test)
    h.test = attribute_text if h.test.nil?
    h.test = nil if h.test == ''

    offset = if h.test != nil
      Condition.true?(h.test) ? 0 : 1
    else
      0
    end

    apply_child_if_present(offset, workitem)

  else # reply from a child

    if h.test != nil || Ruote::FlowExpressionId.child_id(workitem['fei']) != 0

      reply_to_parent(workitem)

    else

      apply_child_if_present(
        workitem['fields']['__result__'] == true ? 1 : 2, workitem)
    end
  end
end

Protected Instance Methods

apply_child_if_present(index, workitem) click to toggle source
# File lib/ruote/exp/fe_if.rb, line 114
def apply_child_if_present (index, workitem)

  if tree_children[index]
    apply_child(index, workitem)
  else
    reply_to_parent(workitem)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.