FenceBuilder
A FenceBuilder
is used to create an extensible Fence
.
An instance of FenceBuilder
will have prototype methods that are created
through the register()
method. When the fork()
method is called all of the
instance's already registered methods will be transferred to a new instance of
FenceBuilder
that is then returned. This is what allows you to 'extend'
a Fence
as you can then continue to register()
methods without mutating
the original FenceBuilder
's prototype.
These prototypical methods are called Invokable
's. An Invokable
is a named
function reference that optionally includes some predefined arguments that can
be used to make specific comparisons. *
Constructor Summary
Public Constructor | ||
public |
constructor(invokables: Array) |
Member Summary
Private Members | ||
private |
_invokables: * |
Method Summary
Public Methods | ||
public |
Convert an instance of |
|
public |
fork(proto: *): FenceBuilder Create a clone of a |
|
public |
hydrate(invokables: String): FenceBuilder Given a string representing a |
|
public |
register(name: String, fn: Function): FenceBuilder Add a named function reference to the prototype of an instance of |
|
public |
serialize(returnFull: *): String Create a representation of an instance of |
|
public |
unregister(name: String): FenceBuilder Remove a named function reference from the prototype of an instance of |
Public Constructors
public constructor(invokables: Array) source
Params:
Name | Type | Attribute | Description |
invokables | Array | A set of already defined |
Private Members
private _invokables: * source
Public Methods
public build(): Fence source
Convert an instance of FenceBuilder
to something that can be used to
validate some value
Return:
Fence | an Object with a |
public fork(proto: *): FenceBuilder source
Create a clone of a FenceBuilder
instance so that it can be extended.
Params:
Name | Type | Attribute | Description |
proto | * |
public hydrate(invokables: String): FenceBuilder source
Given a string representing a serialize
'd FenceBuilder
, attempt to
recreate a list of Invokables
by calling the named prototype references. If
the serialize
'd FenceBuilder
includes a reference to an unavailable
prototype method, an error is thrown.
Params:
Name | Type | Attribute | Description |
invokables | String | A |
public register(name: String, fn: Function): FenceBuilder source
Add a named function reference to the prototype of an instance of FenceBuilder
Params:
Name | Type | Attribute | Description |
name | String | A named function reference |
|
fn | Function | A reference to a validation function |
public serialize(returnFull: *): String source
Create a representation of an instance of FenceBuilder
's Invokable
function reference names and arguments that can be persisted then later used
by hydrate()
recreate an equivalent FenceBuilder
Params:
Name | Type | Attribute | Description |
returnFull | * |
Return:
String | a stringified JSON blob that can be persisted |
public unregister(name: String): FenceBuilder source
Remove a named function reference from the prototype of an instance of FenceBuilder
Params:
Name | Type | Attribute | Description |
name | String | A named function reference |