lib/openwfe/participants/participants.rb in openwferu-0.9.13 vs lib/openwfe/participants/participants.rb in openwferu-0.9.14
- old
+ new
@@ -176,9 +176,38 @@
# else it's a cancel item
end
end
#
+ # Simply aliasing a participant.
+ #
+ # engine.register_participant "toto" do |workitem|
+ # workitem.toto_message = "toto was here"
+ # end
+ # engine.register_participant "user_.*", AliasParticipant.new("toto")
+ #
+ # Workitems for participant whose name starts with 'user_' will be handled
+ # by participant 'toto'.
+ # Note that you can't use use a regex as the aliased name ("toto" in the
+ # example).
+ #
+ class AliasParticipant
+ include LocalParticipant
+
+ attr_reader :aliased_name
+
+ def initialize (aliased_name)
+
+ @aliased_name = aliased_name
+ end
+
+ def consume (workitem)
+
+ get_participant_map.dispatch(nil, @aliased_name, workitem)
+ end
+ end
+
+ #
# The NullParticipant never replies, it simply discards the workitems
# it receives.
#
class NullParticipant
include LocalParticipant