This documentation refers to an UNRELEASED version of Infusion.
View this page in the latest stable release documentation, or visit the latest release documentation home.
If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Skip to end of metadata
Go to start of metadata

This functionality is Sneak Peek status. This means that the APIs may change. We welcome your feedback, ideas, and code, but please use caution if you use this new functionality.

This page is still a rough draft.

fluid.model.transformWithRules(model, rules)

Transforms a model based on a specified expansion rules objects.

File name: ModelTransformations.js

Parameters

model

(Object) the model to transform

rules

(Object) a rules object containing instructions on how to transform the model (see below for more information)

options

(Object) a set of rules governing the transformations. At present this may contain the values:
isomorphic: true indicating that the output model is to be governed by the same schema found in the input model, or
flatSchema holding a flat schema object which consists of a hash of EL path specifications with wildcards, to the values "array"/"object" defining the schema to be used to construct missing trunk values.

Return Value

Object

the transformed model

 

Rules

Rules objects take the form of:

or

Transformation Expanders

The Framework currently provides the following expanders that can be used as part of a model transformation.

  • fluid.transforms.value
  • fluid.transforms.arrayValue
  • fluid.transforms.firstValue
  • fluid.transforms.merge

Each of these is described below.

fluid.transforms.value

This extracts and/or the value of a given path, and can be used for the following purposes:

To rename a property:

Start:



>>

Rule to rename "cat" to "feline":



>>

Result:

To set a default value:

Start:



>>

Rule to set default value of "gerbil":



>>

Result:

Note that if "gerbil" has a value initially, it will be unaffected.

To specify a literal value:

Start:



>>

Rule to set a value for "kangaroo":



>>

Result:

To change the structure/nesting:

Start:



>>

Rule to change the nesting:



>>

Result:

fluid.transforms.arrayValue

The arrayValue expander will transform a value into an aray. If the value is already an array, the expander will have no effect.

For example:

Start:



>>

Rule to convert to arrays:



>>

Result:

Note that the value of cat is now an array, but the value of sheep is unaffected.

fluid.transforms.firstValue

fluid.transforms.merge

Example

In this example, description here...

  • No labels