MNativeObject
MNativeObject ⇐ Trait
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
Name | Type |
---|---|
_nativeObject | Object |
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"}
MNativeObject ⇐Trait
- .getNativeObject(synchronize, bindings) ⇒
Object
- .setNativeObject(nativeObject, synchronize, bindings) ⇒
BusinessModel
- .getNativeObject(synchronize, bindings) ⇒
getNativeObject(synchronize, bindings) ⇒ Object
Return the native object associated to these business model.
Kind: instance method of MNativeObject
Param | Type | Description |
---|---|---|
synchronize | boolean | Should the returned native object be synchronized with the model properties (according to the bindings property) |
bindings | Object | 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
Param | Type | Description |
---|---|---|
nativeObject | Object | The vendor native object |
synchronize | boolean | Should the model be synchronized with the native object properties (according to the bindings property) |
bindings | Object | The bindings map to use (instead of the default one) |