Dispatch to function held internally depending upon the value of stream.

        Matching on directories is partial. This means dictionaries will
        match if all the key/value pairs in the pattern are matched - any extra
        pairs will be ignored.

def dispatch(self, stream, *args, **kwargs):
        """
        Dispatch to function held internally depending upon the value of stream.

        Matching on directories is partial. This means dictionaries will
        match if all the key/value pairs in the pattern are matched - any extra
        pairs will be ignored.

        """
        for f, pat in self.functions:
            matched, matched_stream = self._match(stream, pat, {}, {})
            if matched:
                return f(matched_stream, *args, **kwargs)

        raise DispatchFailed()