LocalParticipant simplification

5 views
Skip to first unread message

John Mettraux

unread,
Jun 28, 2011, 8:32:03 AM6/28/11
to ruote

Hello List,

I've just pushed a set of changes that simplify local participants. For instance, you can rewrite

---8<---
class MyParticipant
include Ruote::LocalParticipant
def consume(workitem)
workitem.fields['message'] = 'this is my participant'
reply_to_engine(workitem)
end
end
--->8---

as

---8<---
class MyParticipant
include Ruote::LocalParticipant
def on_workitem
workitem.fields['message'] = 'this is my participant'
reply
end
end
--->8---

The 'workitem' becomes implicit (ie, an instance method).

The other methods (on_cancel, on_reply, accept?, dont_thread?) have been simplified likewise, with helper methods like fei, fexp, workitem, flavour, lookup_variable popping up.

For more information, please refresh

http://ruote.rubyforge.org/implementing_participants.html

I've updated with [upcoming] ruote 2.2.1 information.

I prefer the on_x scheme, it clearly shows the "hookesque" nature of the participants.

Feel free to fire questions and suggestions, and/or to point me at typos and errors...

It should be 100% backward compatible, if not, please shout.


Best regards,

--
John Mettraux - http://jmettraux.wordpress.com

Reply all
Reply to author
Forward
0 new messages