Class Ruote::Workitem
In: lib/ruote/workitem.rb
Parent: Object

A workitem can be thought of an "execution token", but with a payload (fields).

The payload/fields MUST be JSONifiable.

Methods

==   dispatch_at   dup   eql?   error   fei   fields   fields=   hash   lf   lookup   new   params   participant_name   result   result=   set_field   sid   timed_out   to_h   wfid  

Attributes

h  [R] 

Public Class methods

Public Instance methods

Warning : equality is based on fei and not on payload !

When was this workitem dispatched ?

Returns a complete copy of this workitem.

eql?(other)

Alias for #==

Shortcut for wi.fields[‘error’]

Returns a Ruote::FlowExpressionId instance.

Returns the payload, ie the fields hash.

Sets all the fields in one sweep.

Remember : the fields must be a JSONifiable hash.

Warning : hash is fei‘s hash.

lf(key, container_lookup=false)

Alias for lookup

For a simple key

  workitem.lookup('toto')

is equivalent to

  workitem.fields['toto']

but for a complex key

  workitem.lookup('toto.address')

is equivalent to

  workitem.fields['toto']['address']

Shortcut for wi.fields[‘params’]

When a participant is invoked like in

   participant :ref => 'toto', :task => 'x"

then

   p workitem.params
     # => { 'ref' => 'toto', 'task' => 'x' }

The participant for which this item is destined. Will be nil when the workitem is transiting inside of its process instance (as opposed to when it‘s being delivered outside of the engine).

A shortcut to the value in the field named result

This field is used by the if expression for instance to determine if it should branch to its ‘then’ or its ‘else’.

Sets the value of the ‘special’ field result

See result

Like lookup allows for nested lookups, set_field can be used to set sub fields directly.

  workitem.set_field('customer.address.city', 'Pleasantville')

Warning : if the customer and address field and subfield are not present or are not hashes, set_field will simply create a "customer.address.city" field and set its value to "Pleasantville".

Returns the String id for this workitem (something like "0_0!!20100507-wagamama").

It‘s in fact a shortcut for

  Ruote::FlowExpressionId.to_storage_id(h.fei)

Shortcut for wi.fields[‘timed_out’]

Returns the underlying Hash instance.

Returns the "workflow instance id" (unique process instance id) of the process instance which issued this workitem.

[Validate]