@classmethod
def register_view(cls):
    """Attach view to app or blueprint.
    
    Called by the metaclass when the class is created.
    
    """
    if cls.rules is None:
        raise ValueError('No rules found for %r' % (cls,))
    view = cls.as_view(cls.endpoint)
    allowed_methods = set(cls.methods)
    for rule, methods in cls.rules.items():
        methods = set(methods) & allowed_methods
        if methods:
            cls.__app__.add_url_rule(rule=rule, view_func=view, methods=methods
                )
