MNativeObject

MNativeObject ⇐ Trait

Deprecated

This class represents an helper for business model that needs to handle a reference to a native object.

Kind: global mixin
Extends: Trait
Properties

NameType
_nativeObjectObject

Example

$Model.declare("MyBusinessModel", {
     traits: [$MNativeObject],

     properties: {
         "id": null,
         "title": null,
         "description": null
     },

     methods: {
         _synchronizeModelFromNativeObject: function() {
             this.id = this.getNativeObject().id;
             this.title = this.getNativeObject().program.title;
         }
     }
});

var bmodel = new $MyBusinessModel({id:"modelId",title:"modelTitle",description:"modelDescription"});
var nativeObject = {id:"nativeId", program:{title:"nativeTitle"}};       // Mock
bmodel.setNativeObject(nativeObject);
bmodel.getNativeObject();                    // {id:"nativeId", program:{title:"nativeTitle"}}
bmodel.getNativeObject(true);                // {id:"modelId", program:{title:"modelTitle"}}
nativeObject.id="nativeId";
nativeObject.program.programTitle = "nativeTitle";
bmodel.setNativeObject(nativeObject, true);  // bmodel => {id:"nativeId",title:"nativeTitle",description:"modelDescription"}

getNativeObject(synchronize, bindings) ⇒ Object

Return the native object associated to these business model.

Kind: instance method of MNativeObject

ParamTypeDescription
synchronizeboolean

Should the returned native object be synchronized with the model properties (according to the bindings property)

bindingsObject

The bindings map to use (instead of the default one)

setNativeObject(nativeObject, synchronize, bindings) ⇒ BusinessModel

Set the native object associated with this model.

Kind: instance method of MNativeObject

ParamTypeDescription
nativeObjectObject

The vendor native object

synchronizeboolean

Should the model be synchronized with the native object properties (according to the bindings property)

bindingsObject

The bindings map to use (instead of the default one)