Class: ClassFactory

FooTable.ClassFactory

new ClassFactory() → {FooTable.ClassFactory}

This is a simple factory for FooTable.Class objects allowing them to be registered using a friendly name and then new instances can be created using this friendly name.
This:
Returns:
Type
FooTable.ClassFactory

Extends

Members

registered :Object

An object containing all registered classes.
Type:
  • Object

Methods

(private) _make(klass, args) → {FooTable.Class}

This in effect lets us use the "apply" method on a function using the "new" keyword.
This:
Parameters:
Name Type Description
klass function
args
Returns:
Type
FooTable.Class

contains(name) → {boolean}

Checks if the factory contains a class registered using the supplied name.
This:
Parameters:
Name Type Description
name string The name of the class to check.
Returns:
Type
boolean

load(arg1) → {Array.<FooTable.Class>}

Creates new instances of all registered classes using there priority and the supplied arguments to return them in an array.
This:
Parameters:
Name Type Attributes Description
arg1 * The first argument to supply when creating new instances of all registered classes.
argN... * <optional>
Any number of additional arguments to supply when creating new instances of all registered classes.
Returns:
Type
Array.<FooTable.Class>

make(name, arg1) → {FooTable.Class}

Create a new instance of a single class using the supplied name and arguments.
This:
Parameters:
Name Type Attributes Description
name string The name of the class to create.
arg1 * The first argument to supply to the new instance.
argN... * <optional>
Any number of additional arguments to supply to the new instance.
Returns:
Type
FooTable.Class

names() → {Array.<string>}

Gets an array of all registered names.
This:
Returns:
Type
Array.<string>

register(name, klass, priority)

Registers a class object using the supplied friendly name and priority. The priority is only taken into account when loading all registered classes using the FooTable.ClassFactory#load method.
This:
Parameters:
Name Type Description
name string The friendly name of the class.
klass function The class to register.
priority number This determines the order that the class is created when using the FooTable.ClassFactory#load method, higher values are loaded first.