Package pypat :: Package creational :: Module builder :: Class Builder
[hide private]
[frames] | no frames]

Class Builder

source code


Abstract builder class, responsible for constructing various pieces of an object.

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

Instance Methods [hide private]
 
__init__(self, constructed_object)
Initialize a new Builder.
source code
 
build(self, build_option, **kwargs)
Build a piece of the constructed object.
source code
 
_register(self, build_option, build_method)
Register a build option to a build method.
source code
Method Details [hide private]

__init__(self, constructed_object)
(Constructor)

source code 

Initialize a new Builder.

Concrete Builders should call this method from within their own __init__ method. The concrete __init__ method should also register all build options to build methods, by using the _register method.

Parameters:
  • constructed_object - An instance of an object this builder is responsible for.

build(self, build_option, **kwargs)

source code 

Build a piece of the constructed object.

Parameters:
  • build_option (str) - The part of the object to build. All build options should have been registered in __init__.
  • kwargs - Additional arguments for building.

_register(self, build_option, build_method)

source code 

Register a build option to a build method.

All concrete builders should call this method in their constructor at least once.

Parameters:
  • build_option (str) - A string representing the part of the object to build.
  • build_method - The method to call when given build option is selected.