def lookup_code

      wi = workitem

      rev = wi.params['revision'] || wi.params['rev']

      [
        [ wi.wf_name, wi.wf_revision, wi.participant_name, rev ],
        [ wi.wf_name, wi.wf_revision, wi.participant_name ],
        [ wi.wf_name, '', wi.participant_name ],
        [ wi.participant_name, rev ],
        [ wi.participant_name ],
      ].each do |fname|

        fname = File.join(@dir, "#{fname.compact.join('__')}.rb")
        next unless File.exist?(fname)

        cpart = Class.new
        cpart.send(:include, Ruote::LocalParticipant)
        cpart.module_eval(File.read(fname))
        part = cpart.new
        part.context = @context

        next if part.respond_to?(:accept?) and (not part.accept?(wi))

        return part
      end

      raise ArgumentError.new(
        "couldn't find code for participant #{wi.participant_name} " +
        "in dir #{@dir}"
      )
    end
def lookup_code

      wi = workitem

      rev = wi.params['revision'] || wi.params['rev']

      [
        [ wi.wf_name, wi.wf_revision, wi.participant_name, rev ],
        [ wi.wf_name, wi.wf_revision, wi.participant_name ],
        [ wi.wf_name, '', wi.participant_name ],
        [ wi.participant_name, rev ],
        [ wi.participant_name ],
      ].each do |fname|

        fname = File.join(@dir, "#{fname.compact.join('__')}.rb")
        next unless File.exist?(fname)

        cpart = Class.new
        cpart.send(:include, Ruote::LocalParticipant)
        cpart.module_eval(File.read(fname))
        part = cpart.new
        part.context = @context

        next if part.respond_to?(:accept?) and (not part.accept?(wi))

        return part
      end

      raise ArgumentError.new(
        "couldn't find code for participant #{wi.participant_name} " +
        "in dir #{@dir}"
      )
    end
Maybe "lookup_real_participant_code" would be a better name...