Class metawidget.Pipeline
Convenience implementation for implementing pipelines (see http://metawidget.org/doc/reference/en/html/ch02.html).
Specifically, BasePipeline provides support for:
- Inspectors, InspectionResultProcessors, WidgetBuilders, WidgetProcessors and Layouts
- single/compound widgets
- stubs/stub attributes
- read-only/active widgets
- maximum inspection depth
Defined in: metawidget.js.
Constructor Attributes | Constructor Name and Description |
---|---|
metawidget.Pipeline(element)
|
Method Attributes | Method Name and Description |
---|---|
buildWidgets(inspectionResult, mw)
Build widgets from the given JSON inspection result.
|
|
configure(config)
Configures the pipeline using the given config object.
|
|
getWidgetProcessor(testInstanceOf)
Searches the pipeline's current list of WidgetProcessors and matches each
against the given function
|
|
inspect(toInspect, type, names, mw)
Inspect the 'toInspect' according to its 'type' and 'names', and return
the result as a JSON String.
|
|
layoutWidget(widget, elementName, attributes, container, mw)
Layout the given widget by delegating to the configured Layout.
|
Note: the Pipeline expects the JSON to be passed in externally, rather than fetching it itself, because some JSON inspections may be asynchronous.
- Parameters:
- inspectionResult
- array of metadata to base widgets on.
- mw
- Metawidget instance that will be passed down the pipeline (WidgetBuilders, WidgetProcessors etc). Expected to have 'toInspect', 'path' and 'readOnly'.
This method is separate to the constructor, so that subclasses can set defaults. The following configuration properties are supported:
- inspector - an Inspector
- inspectionResultProcessors - an array of InspectionResultProcessors
- widgetBuilder - a WidgetBuilder
- widgetProcessors - an array of WidgetProcessors
- layout - a Layout
- Parameters:
- config
- the config object to use. This can be an array, in which case multiple configs will be applied (in the order they appear in the array)
- Parameters:
- testInstanceOf
- a function that accepts a WidgetProcessor and will perform an 'instanceof' test on it
This method mirrors the Inspector
interface. Internally it
looks up the Inspector to use. It is a useful hook for subclasses wishing
to inspect different Objects using our same Inspector
.
In addition, this method runs the InspectionResultProcessors
.
- Parameters:
- toInspect
- type
- names
- mw
Subclasses can override this method to perform any post-processing of the widget, following layout. For pre-processing, subclasses should use a WidgetProcessor.
- Parameters:
- widget
- elementName
- attributes
- container
- mw