Add fallback decorators -- otherwise
This commit is contained in:
parent
024c429af1
commit
aa6407ff37
@ -106,6 +106,13 @@ class FunctionDispatcher(object):
|
||||
return self
|
||||
return register_rule
|
||||
|
||||
@property
|
||||
def otherwise(self):
|
||||
def register_rule(func):
|
||||
self.register_rule(func, [object]*self.params_arity)
|
||||
return self
|
||||
return register_rule
|
||||
|
||||
def override(self, *argtypes):
|
||||
def override_rule(func):
|
||||
self.override_rule(func, *argtypes)
|
||||
@ -158,6 +165,13 @@ class MethodDispatcher(FunctionDispatcher):
|
||||
|
||||
override = when
|
||||
|
||||
@property
|
||||
def otherwise(self):
|
||||
def make_declaration(func):
|
||||
self.register_unbound_rule(func, [object]*self.params_arity)
|
||||
return self
|
||||
return make_declaration
|
||||
|
||||
|
||||
def arity(argspec):
|
||||
""" Determinal positional arity of argspec."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user