Class: Ruote::Exp::RegisterpExpression

Inherits:
FlowExpression show all
Defined in:
lib/ruote/exp/fe_registerp.rb

Overview

This expressions lets one register participants directly from a process definition.

pdef = Ruote.define do

  registerp 'alpha', :class => 'MyParticipant', :target => 'mail'
    # register participant named 'alpha' with the given class
    # and some attributes

  registerp /^user_.+/, :class => 'MyParticipant'
  registerp :regex => '^user_.+', :class => 'MyParticipant'
    # register participant with a given regular expression

  registerp 'admin', :class => 'MyParticipant', :position => -2
    # register participant 'admin' as second to last in participant list
end

Participant info can be given as attributes to the expression (see code above) or via the workitem.

pdef = Ruote.define do

  registerp :participant => 'participant'
    # participant info is found in the field 'participant'

  registerp :participants => 'participants'
    # an array of participant info is found in the field 'participants'
end

The expression ‘unregisterp’ can be used to remove participants from the participant list.

Direct Known Subclasses

UnregisterpExpression

Constant Summary

Constants inherited from FlowExpression

FlowExpression::COMMON_ATT_KEYS

Instance Attribute Summary

Attributes inherited from FlowExpression

#context, #error, #h

Instance Method Summary collapse

Methods inherited from FlowExpression

#ancestor?, #applied_workitem, #att, #att_text, #attribute, #attribute_text, #attributes, #await, #cancel, #cancel_flanks, #cfei_at, #child_id, #child_ids, #compile_atts, #compile_variables, #debug_id, #deflate, #do, do_action, #do_apply, #do_cancel, #do_fail, #do_pause, #do_persist, #do_reply, #do_reply_to_parent, #do_resume, #do_unpersist, dummy, #fei, fetch, from_h, #handle_on_error, #has_attribute, #initial_persist, #initialize, #is_concurrent?, #iterative_var_lookup, #launch_sub, #lookup_val, #lookup_val_prefix, #lookup_variable, #name, names, #parent, #parent_id, #pause_on_apply, #persist_or_raise, #reply_to_parent, #root, #root_id, #set_variable, #to_h, #tree, #tree_children, #try_persist, #try_unpersist, #unpersist_or_raise, #unset_variable, #update_tree, #variables, #wfid

Methods included from WithMeta

#class_def, included

Methods included from WithH

included

Constructor Details

This class inherits a constructor from Ruote::Exp::FlowExpression

Instance Method Details

#applyObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ruote/exp/fe_registerp.rb', line 65

def apply

  registerp_allowed?

  if pa = attribute('participant')

    register_participant(h.applied_workitem['fields'][pa])

  elsif pas = attribute('participants')

    h.applied_workitem['fields'][pas].each do |part|
      register_participant(part)
    end

  else

    register_participant(attributes)
  end

  reply_to_parent(h.applied_workitem)
end

#reply(workitem) ⇒ Object



87
88
89
90
# File 'lib/ruote/exp/fe_registerp.rb', line 87

def reply(workitem)

  # never called
end