lib/openwfe/participants/participantmap.rb in openwferu-0.9.4 vs lib/openwfe/participants/participantmap.rb in openwferu-0.9.5
- old
+ new
@@ -65,25 +65,37 @@
#
# Adds a participant to this map.
# This method is called by the engine's own register_participant()
# method.
#
+ # The participant instance is returned by this method call
+ #
def register_participant (regex, participant=nil, &block)
if not participant
raise "please provide a participant instance or a block" \
if not block
participant = BlockParticipant.new(block)
end
+ if participant.kind_of? Class
+ begin
+ participant = participant.new(regex, @application_context)
+ rescue
+ participant = participant.new
+ end
+ end
+
regex = Regexp.new(regex.to_s) unless regex.kind_of? Regexp
participant.application_context = @application_context \
if participant.respond_to? :application_context=
@participants << [ regex, participant ]
+
+ return participant
end
#
# Looks up a participant given a participant_name.
# Will return the first participant whose name matches.