@@ -3,10 +3,6 @@ import { Util } from './BaseModel.utils';
3
3
import { ConversionTypeEnum } from './BaseModel.constants' ;
4
4
import { BaseModelJson , IBaseModel , IBaseModelOptions , IConversionOption } from './BaseModel.types' ;
5
5
6
- const sjsOptions : IBaseModelOptions = {
7
- expand : false ,
8
- } ;
9
-
10
6
/**
11
7
* BaseModel is a design pattern used to transfer data between software application subsystems.
12
8
*
@@ -71,10 +67,14 @@ export class BaseModel extends BaseObject implements IBaseModel {
71
67
*/
72
68
public static readonly IS_BASE_MODEL : boolean = true ;
73
69
70
+ #sjsOptions: IBaseModelOptions = {
71
+ expand : false ,
72
+ } ;
73
+
74
74
constructor ( opts : IBaseModelOptions = { } ) {
75
75
super ( ) ;
76
76
77
- sjsOptions . expand = opts . expand === true ;
77
+ this . # sjsOptions. expand = opts . expand === true ;
78
78
}
79
79
80
80
/**
@@ -178,11 +178,11 @@ export class BaseModel extends BaseObject implements IBaseModel {
178
178
Array . isArray ( passedInDataForProperty ) === false ? [ passedInDataForProperty ] : passedInDataForProperty ;
179
179
180
180
if ( isBaseModelClass ) {
181
- return arrayData . map ( ( json : object ) => new fistItemInArray ( json , sjsOptions ) ) ;
181
+ return arrayData . map ( ( json : object ) => new fistItemInArray ( json , this . # sjsOptions) ) ;
182
182
}
183
183
184
184
if ( isBaseModelObject ) {
185
- return arrayData . map ( ( json : object ) => new ( fistItemInArray as any ) . constructor ( json , sjsOptions ) ) ;
185
+ return arrayData . map ( ( json : object ) => new ( fistItemInArray as any ) . constructor ( json , this . # sjsOptions) ) ;
186
186
}
187
187
188
188
return arrayData ;
@@ -207,12 +207,12 @@ export class BaseModel extends BaseObject implements IBaseModel {
207
207
return baseModel ;
208
208
}
209
209
210
- if ( isBaseModelClass && ( isPassedInDataAnObjectWithProperties || sjsOptions . expand === true ) ) {
210
+ if ( isBaseModelClass && ( isPassedInDataAnObjectWithProperties || this . # sjsOptions. expand === true ) ) {
211
211
// If data is passed in or the expand option is set to true then create the BaseModel.
212
212
// Give the constructor the passed in data or an empty object if expand is true.
213
213
const obj : object = isPassedInDataAnObjectWithProperties ? passedInDataForProperty : { } ;
214
214
215
- return new currentPropertyData ( obj , sjsOptions ) ;
215
+ return new currentPropertyData ( obj , this . # sjsOptions) ;
216
216
} else if ( isBaseModelClass ) {
217
217
// Don't create the BaseModel if there is no data passed in. Return null to be assigned to the property.
218
218
return null ;
0 commit comments