File tree Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -468,7 +468,7 @@ export class JSORMBase {
468
468
let attributeName = key
469
469
470
470
if ( this . klass . camelizeKeys ) {
471
- attributeName = this . deserializeKey ( key )
471
+ attributeName = this . klass . deserializeKey ( key )
472
472
}
473
473
474
474
if ( key === "id" || this . klass . attributeList [ attributeName ] ) {
@@ -694,6 +694,17 @@ export class JSORMBase {
694
694
return this . baseClass
695
695
}
696
696
697
+ static serializeKey ( key : string ) : string {
698
+ if ( this . letterCase == "dasherized" ) {
699
+ return dasherize ( underscore ( key ) )
700
+ }
701
+ return underscore ( key )
702
+ }
703
+
704
+ static deserializeKey ( key : string ) : string {
705
+ return camelize ( underscore ( key ) , false )
706
+ }
707
+
697
708
async destroy ( ) : Promise < boolean > {
698
709
const url = this . klass . url ( this . id )
699
710
const verb = "delete"
@@ -741,17 +752,6 @@ export class JSORMBase {
741
752
} )
742
753
}
743
754
744
- serializeKey ( key : string ) : string {
745
- if ( this . klass . letterCase == "dasherized" ) {
746
- return dasherize ( underscore ( key ) )
747
- }
748
- return underscore ( key )
749
- }
750
-
751
- deserializeKey ( key : string ) : string {
752
- return camelize ( underscore ( key ) , false )
753
- }
754
-
755
755
private async _handleResponse (
756
756
response : JsonapiResponse ,
757
757
callback : ( ) => void
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export class ValidationErrors {
43
43
let attribute = meta . attribute
44
44
45
45
if ( this . model . klass . camelizeKeys ) {
46
- attribute = this . model . deserializeKey ( attribute )
46
+ attribute = this . model . klass . deserializeKey ( attribute )
47
47
}
48
48
49
49
errorsAccumulator [ attribute ] = meta . message
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export class WritePayload<T extends JSORMBase> {
33
33
34
34
this . _eachAttribute ( ( key , value ) => {
35
35
if ( ! this . model . isPersisted || this . model . changes ( ) [ key ] ) {
36
- attrs [ this . model . serializeKey ( key ) ] = value
36
+ attrs [ this . model . klass . serializeKey ( key ) ] = value
37
37
}
38
38
} )
39
39
@@ -120,7 +120,7 @@ export class WritePayload<T extends JSORMBase> {
120
120
}
121
121
122
122
if ( data ) {
123
- _relationships [ this . model . serializeKey ( key ) ] = { data }
123
+ _relationships [ this . model . klass . serializeKey ( key ) ] = { data }
124
124
}
125
125
}
126
126
} )
You can’t perform that action at this time.
0 commit comments