Skip to content

Commit 027c945

Browse files
committed
chore: method ordering
1 parent 71c575d commit 027c945

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

src/mixins/Model.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,10 @@ export default function Model(
66
model: typeof BaseModel
77
): void {
88
/**
9-
* Add supporting attributes to models.
10-
*/
11-
const $fields = model.prototype.$fields
12-
13-
model.prototype.$fields = function() {
14-
const fields = $fields.call(this)
15-
16-
const { key, flagName } = context.createConfig(
17-
this.$self().softDeleteConfig
18-
)
19-
20-
return Object.assign({}, fields, {
21-
[key]: this.$self().attr(null),
22-
[flagName]: this.$self().attr(false)
23-
})
24-
}
25-
26-
/**
27-
* Flags are visible by default during model serialization. They can be hidden
28-
* by setting `exposeFlagsExternally` to false globally or locally on models.
9+
* Trash record(s) matching a condition.
2910
*/
30-
const $toJson = model.prototype.$toJson
31-
32-
model.prototype.$toJson = function() {
33-
const toJson = $toJson.call(this)
34-
35-
const config = context.createConfig(this.$self().softDeleteConfig)
36-
37-
if (config.exposeFlagsExternally !== true) {
38-
/* istanbul ignore next */
39-
const { [config.key]: k, [config.flagName]: fn, ...json } = toJson
40-
41-
return json
42-
}
43-
44-
return toJson
11+
model.softDelete = function(payload: any) {
12+
return this.dispatch('softDelete', payload)
4513
}
4614

4715
/**
@@ -95,9 +63,41 @@ export default function Model(
9563
}
9664

9765
/**
98-
* Trash record(s) matching a condition.
66+
* Add supporting attributes to models.
9967
*/
100-
model.softDelete = function(payload: any) {
101-
return this.dispatch('softDelete', payload)
68+
const $fields = model.prototype.$fields
69+
70+
model.prototype.$fields = function() {
71+
const fields = $fields.call(this)
72+
73+
const { key, flagName } = context.createConfig(
74+
this.$self().softDeleteConfig
75+
)
76+
77+
return Object.assign({}, fields, {
78+
[key]: this.$self().attr(null),
79+
[flagName]: this.$self().attr(false)
80+
})
81+
}
82+
83+
/**
84+
* Flags are visible by default during model serialization. They can be hidden
85+
* by setting `exposeFlagsExternally` to false globally or locally on models.
86+
*/
87+
const $toJson = model.prototype.$toJson
88+
89+
model.prototype.$toJson = function() {
90+
const toJson = $toJson.call(this)
91+
92+
const config = context.createConfig(this.$self().softDeleteConfig)
93+
94+
if (config.exposeFlagsExternally !== true) {
95+
/* istanbul ignore next */
96+
const { [config.key]: k, [config.flagName]: fn, ...json } = toJson
97+
98+
return json
99+
}
100+
101+
return toJson
102102
}
103103
}

test/feature/module/Deprecated.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createStore, createState } from 'test/support/Helpers'
22
import { Model } from '@vuex-orm/core'
33

4-
describe('Feature - Model - Deprecated', () => {
4+
describe('Feature - Module - Deprecated', () => {
55
const mockDate = Date.now()
66
const spyOnDate = jest.spyOn(Date, 'now').mockImplementation(() => mockDate)
77

test/feature/module/Retrieve_All.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createStore } from 'test/support/Helpers'
22
import { Model } from '@vuex-orm/core'
33

4-
describe('Feature - Module - Retrieve', () => {
4+
describe('Feature - Module - Retrieve All', () => {
55
const mockDate = Date.now()
66
const spyOnDate = jest.spyOn(Date, 'now').mockImplementation(() => mockDate)
77

0 commit comments

Comments
 (0)