'Context manager which resolves a JSON ``ref`` and enters the
resolution scope of this ref.
:argument str ref: reference to resolve'

@contextlib.contextmanager
def resolving(self, ref):

    full_uri = urljoin(self.resolution_scope, ref)
    (uri, fragment) = urldefrag(full_uri)
    if (not uri):
        uri = self.base_uri
    if (uri in self.store):
        document = self.store[uri]
    else:
        try:
            document = self.resolve_remote(uri)
        except Exception as exc:
            raise RefResolutionError(exc)
    (old_base_uri, self.base_uri) = (self.base_uri, uri)
    try:
        with self.in_scope(uri):
            (yield self.resolve_fragment(document, fragment))
    finally:
        self.base_uri = old_base_uri
