lib/openwfe/participants/participantmap.rb in openwferu-0.9.14 vs lib/openwfe/participants/participantmap.rb in openwferu-0.9.15

- old
+ new

@@ -55,12 +55,13 @@ attr_accessor \ :participants def initialize (service_name, application_context) - super(service_name, application_context) + super + @participants = [] @observers = {} end @@ -182,20 +183,13 @@ unless participant end workitem.participant_name = participant_name - if (workitem.kind_of?(CancelItem) and - participant.respond_to?(:cancel)) + return cancel(participant, workitem) \ + if workitem.is_a?(CancelItem) - participant.cancel(workitem) - - onotify :dispatch, :cancel, workitem - - return - end - onotify :dispatch, :before_consume, workitem workitem.dispatch_time = Time.now participant.consume(workitem) @@ -207,9 +201,27 @@ # The method onotify (from Osbservable) is made public so that # ParticipantExpression instances may notify the pmap of applies # and replies. # public :onotify + + protected + + # + # Will call the cancel method of the participant if it has + # one, or will simply discard the cancel item else. + # + def cancel (participant, cancel_item) + + participant.cancel(cancel_item) \ + if participant.respond_to?(:cancel) + + onotify :dispatch, :cancel, cancel_item + # + # maybe it'd be better to specifically log that + # a participant has no cancel() method, but it's OK + # like that for now. + end end end