@classmethod<EOL><INDENT>def register_fn(cls, f):<DEDENT>
def inner(self, *args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>query, projection, options = cls.unpack_scope(f(*args, **kwargs))<EOL>new_query = deepcopy(self.query)<EOL>new_projection = deepcopy(self.projection)<EOL>new_options = deepcopy(self.options)<EOL>deep_merge(query, new_query)<EOL>new_projection.update(projection)<EOL>new_options.update(options)<EOL>return ScopeBuilder(self.model, self.fns, new_query,<EOL>new_projection, new_options)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ValueError("<STR_LIT>".format(f.__name__))<EOL><DEDENT><DEDENT>setattr(cls, f.__name__, inner)<EOL>
Registers a scope function on this builder.