# File lib/ruote/part/participant_list.rb, line 50
    def register (name, participant, options, block)

      options = options.inject({}) { |h, (k, v)|
        h[k.to_s] = v.is_a?(Symbol) ? v.to_s : v
        h
      }

      entry = if participant.is_a?(Class) || participant.is_a?(String)
        [ participant.to_s, options ]
      else
        "inpa_#{name.inspect}"
          # INstantiated PArticipant
      end

      key = (name.is_a?(Regexp) ? name : Regexp.new("^#{name}$")).source

      entry = [ key, entry ]

      list = get_list

      list['list'].delete_if { |e| e.first == key }

      position = options['position'] || 'last'
      case position
        when 'last' then list['list'] << entry
        when 'first' then list['list'].unshift(entry)
        when Fixnum then list['list'].insert(position, entry)
        else raise "cannot insert participant at position '#{position}'"
      end

      if r = @context.storage.put(list)
        #
        # if put returns something it means the put failed, have to redo the
        # work...
        #
        return register(name, participant, options, block, r)
      end

      if entry.last.is_a?(String)

        participant = BlockParticipant.new(block, options) if block

        participant.context = @context if participant.respond_to?(:context=)
        @instantiated_participants[entry.last] = participant
        #participant

      else

        if entry.last.first == 'Ruote::StorageParticipant'
          return Ruote::StorageParticipant.new(@context)
        end

        nil
      end
    end