File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed
Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -44,28 +44,36 @@ export abstract class ModelBase {
4444 if ( ! params ) {
4545 return ;
4646 }
47-
47+ if ( typeof params ?. json === 'function' ) {
48+ params = params . json ( ) ;
49+ }
4850 for ( const paramKey in params ) {
4951 if ( ! params [ paramKey ] ) {
5052 continue ;
5153 }
5254 const paramValue = params [ paramKey ] ;
5355 if ( this . PARAMS_MAPPER [ paramKey ] ) {
54- this [ paramKey ] = this . parseParam ( paramKey , paramValue ) ;
56+ // Parser will be executed by the setter
57+ this [ paramKey ] = paramValue ;
5558 }
5659 }
5760 }
5861
5962 parseParam ( key : string , value : any ) : any {
6063 const mapper = this . PARAMS_MAPPER [ key ] ;
61- if (
62- mapper &&
63- typeof mapper ?. type === 'function' &&
64- typeof value !== 'function' &&
65- value ?. __proto__ ?. constructor ?. name !== 'Array'
66- ) {
64+ if ( ! mapper ) {
65+ return value ;
66+ }
67+ if ( value ?. __proto__ ?. constructor ?. name === 'Array' ) {
68+ if ( value [ 0 ] ?. constructor . name !== mapper . type ?. name ) {
69+ return recursiveInstance ( mapper . type , value ) ;
70+ }
71+ return value ;
72+ }
73+ if ( typeof mapper ?. type === 'function' && typeof value !== 'function' ) {
6774 return recursiveInstance ( mapper . type , value ) ;
6875 }
76+
6977 return value ;
7078 }
7179
You can’t perform that action at this time.
0 commit comments