On Thu, Jun 20, 2013 at 05:22:49AM -0700, [email protected] wrote:
>
> Regarding my question about assigning a user to a step, is something like
> this possible today?
>
> ```ruby
>   Ruote.define do
>     prepare_doc :assigned_to => 'mary'
>     advise_on_doc :assigned_to => 'joe'
>     approve_reject :assigned_to => 'lauren'
>   end
> ```

Yes, it's possible.

> We'd like to be able to define arbitrary key/value pairs on a participant
> within a process definition, and then be able to access this meta data when
> a process instance is launched (both from within the participant
> implementation, as well as from the outside by querying the process
> instance).

```ruby
  class PrepareDoc < Ruote::Participant
    def on_workitem
      p workitem.params
      reply
    end
  end

  ruote.register do
    prepare_doc PrepareDoc
  end
```

When running the flow you wrote above, that participant implementations would
print something like:

```
{'assigned_to' => 'mary'}
```

For the "querying the process instance" part:

Process definition are turned into syntax trees by ruote.

```
[ 'define', {}, [
  [ 'prepare_doc', { 'assigned_to' => 'mary' }, [] ],
  [ 'advise_on_doc', { 'assigned_to' => 'joe' }, [] ],
  [ 'approve_reject', { 'assigned_to' => 'lauren' }, [] ]
] ]
```

The root expression of a workflow instance contains a copy of that tree, so
it's accessible somehow.

Note that if you do something like

```ruby
  Ruote.define do
    set 'this_user' => 'mary'
    prepare_doc :assigned_to => '${f:this_user}'
    advise_on_doc :assigned_to => '${f:that_user}'
    approve_reject :assigned_to => '${f:that_other_user}'
  end
```

the tree will look like

```
[ 'define', {}, [
  [ 'set', { 'this_user' => 'mary' }, [] ],
  [ 'prepare_doc', { 'assigned_to' => '${f:this_user}' }, [] ],
  [ 'advise_on_doc', { 'assigned_to' => '${f:that_user}' }, [] ],
  [ 'approve_reject', { 'assigned_to' => '${f:that_other_user}' }, [] ]
] ]
```

The attribute substitution (dollar notation) happens when necessary and at
the local node level (not in the copy of the tree kept at the root
node/expression level).


> We can think of some other uses for defining meta-data/configuration on
> participants as part of the process definition, so hopefully this is
> supported or wouldn't be difficult to add.

Ruote will not prevent you from adding attributes to the process definition.
It will simply ignore attributes it doesn't use.


Best regards,

--
John Mettraux   -   http://lambda.io/jmettraux

-- 
-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"ruote" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to