pytilities.overloading.overloader.Overloader

Package pytilities :: Package overloading :: Module overloader :: Class Overloader |
[hide private]
[frames] | no frames]

# Class Overloader

source code

    object --+
             |
            Overloader

A collection of `Overload`s that can process calls.

Tool for overloading operations.

Has an ordered collection of overloads which serve as rules, the operation of the matching overload is called. If none match, an assertion error is raised.

Methods:

> - process_call: Process a call with given args and keyword args

Instance Methods | [hide private]
__init__(self, overloads, add_self=True) Construct an Overloader. | source code
process_call(self, args, kwargs) Process a call with given args and keyword args. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, overloads, add_self=True) (Constructor) | source code
Construct an Overloader. Parameters: `overloads` :: (Overload...) a collection of rules indicating which operation to call for which combination of arguments/parameters. Note: the order can effect which overload is matched as the first matching overload is used. Must specify at least one overload. `add_self` :: bool = True if True, a "self" parameter is inserted at the beginning of the parameter list of each overload Overrides: object.__init__

### process_call(self, args, kwargs) | source code
Process a call with given args and keyword args. The matching overload is called. Parameters: `args`, `kwargs' arguments of the call Returns the return value of the called operation