docs: def register_fn(cls, f):
          """Registers a scope function on this builder."""
          def inner(self, *args, **kwargs):
              try:
                  query, projection, options = cls.unpack_scope(f(*args, **kwargs))
                  new_query = deepcopy(self.query)
                  new_projection = deepcopy(self.projection)
                  new_options = deepcopy(self.options)
                  deep_merge(query, new_query)
                  new_projection.update(projection)
                  new_options.update(options)
                  return ScopeBuilder(self.model, self.fns, new_query,
                      new_projection, new_options)
              except ValueError:
                  raise ValueError("Scope function \"{}\ returns an invalid scope".format(f.__name__))
  
          setattr(cls, f.__name__, inner)