Class: ArrayFactory

nationscript/factory~ArrayFactory()

A special factory that is not finalised after producing only a single product, instead producing multiple instances for a collection of products.

Constructor

new ArrayFactory()

Methods

(static) complex(tag, create)

Creates a new ArrayFactory that assigns the given sub-factory to itself upon encountering the given tag name.

Parameters:
Name Type Description
tag string

Name of the tag to handle

create function

Creator function for the sub-factory

(static) primitive(tag, convert)

Creates a new ArrayFactory that produces the text content of tags with the given name, converted by the given function, as its products.

Parameters:
Name Type Description
tag string

Name of the tag to handle

convert DataConverter

Converter function for tag content

(static) single(tag, handler)

Creates a new ArrayFactory with the given handler assigned to the given single tag name.

Parameters:
Name Type Description
tag string

Name of the tag to handle

handler TagHandler

Handler function for the tag

addToProduct()

Finally, the product gets pushed to this factory's collection.

deliver() → {Array.<ProductType>}

Requests delivery of the collection of this factory. If it isn't finalised yet, the factory will withhold the collection.

Throws:

The collection must be finalised!

Type
ProductWithheldError
Returns:

The collection.

Type
Array.<ProductType>