Package pypat :: Package creational :: Module factory :: Class AbstractFactory
[hide private]
[frames] | no frames]

Class AbstractFactory

source code


Abstract Factory Class as part of the AbstractFactory design pattern.

- External Usage documentation: U{https://github.com/tylerlaberge/PyPatterns/wiki/Creational-Pattern-Usage}
- External Abstract Factory Pattern documentation: U{https://en.wikipedia.org/wiki/Abstract_factory_pattern}

Instance Methods [hide private]
 
__init__(self)
Initialize the abstract factory.
source code
 
create(self, **kwargs)
Abstract create method.
source code
 
_register(self, key, factory)
Register a factory to a key.
source code
Method Details [hide private]

__init__(self)
(Constructor)

source code 

Initialize the abstract factory.

Concrete implementations should call this from within their own __init__ method and register all their factories to keys using the register method.

create(self, **kwargs)

source code 

Abstract create method.

Concrete implementations should return a new instance of an object by calling the appropriate factory.

Parameters:
  • kwargs - Arguments for object creation.
Decorators:
  • @abstractmethod

_register(self, key, factory)

source code 

Register a factory to a key.

Parameters:
  • key (str) - Key for identifying which factory to use.
  • factory - The factory to register to the key.