Hi John,
sorry for my late answer, I was away from any computer for a short vacation.
If you come up with something elegant that'd be much appreciated.
I'll try and I'll let you know.
Please keep in mind that #consume, #on_reply and co are callback methods
> (granted, #update is not). Maybe I should make it more obvious.
>
> Participant#on_workitem(wi)
> Participant#on_cancel(fei, flavour)
> Participant#on_pause(fei)
> Participant#on_resume(fei)
>
> Why not ? It would be make the participant concept much easier to grasp.
>
Yes, I agree. Using the on_ prefix will make them more easier to understand.
At least, the prefix differentiate them from "standard" methods.
Also, in my mind a callback method should have two important properties:
1. it should be an optional method and you should be free to define it or
not
2. it should not be already defined, otherwise you always have to care
about not overriding the original implementation.
You said #consume is a callback. But currently, when I wrote the following
custom participant
class Alpha < Ruote::StorageParticipant
def consume(workitem)
# ...
super
end
end
I must be sure to call #super, otherwise I permanently loose all the logic
defined within the original StorageParticipant#consume method.
Ideally, I would love to be able to write something like
class Alpha < Ruote::StorageParticipant
def on_consume(workitem)
# ...
end
end
and have Ruote automatically invoke the method if defined. This means the
original StorageParticipant#consume should be modified to
def consume(workitem)
# call the callback if available
on_consume(workitem) if respond_to?(:on_consume)
doc = workitem.to_h
doc.merge!(
'type' => 'workitems',
'_id' => to_id(doc['fei']),
'participant_name' => doc['participant_name'],
'wfid' => doc['fei']['wfid'])
doc['store_name'] = @store_name if @store_name
@context.storage.put(doc)
end
This opens the door to several additional features. For instance, we can
have after/before callbacks.
class Alpha < Ruote::StorageParticipant
def before_consume(workitem)
# ...
end
def after_consume(workitem)
# ...
end
end
It would be cool to be able to attach callbacks to the Ruote core as well,
regardless the participant you use.
Again, I'll try to formulate a more concrete proposal as soon as possible.
Also, I'll double check your code. I didn't notice you can override a single
method even if aliased. I'll try it.
Thanks,
-- Simone
--
Simone Carletti
Application Developer
Site & Blog: http://www.simonecarletti.com
Email: [email protected]
LinkedIn: http://linkedin.com/in/weppos
Skype: weppos
--
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