Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 31 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /** |
||
2 | * |
||
3 | */ |
||
4 | import {ModelInterface, ModelStaticInterface, QueueAble} from "../../../JeloquentInterfaces"; |
||
5 | |||
6 | export default class QueueMessage implements QueueAble { |
||
7 | |||
8 | private action: string; |
||
9 | |||
10 | private callback: CallableFunction; |
||
11 | |||
12 | private data: object|Array<object>; |
||
13 | |||
14 | private model: ModelInterface|ModelStaticInterface; |
||
15 | |||
16 | constructor(model: ModelInterface|ModelStaticInterface, action: string, data:object|Array<object>) { |
||
17 | this.model = model; |
||
18 | this.action = action; |
||
19 | this.data = data; |
||
20 | this.callback = () => null; |
||
21 | } |
||
22 | |||
23 | addCallback(callback: CallableFunction): void { |
||
24 | this.callback = callback; |
||
25 | } |
||
26 | |||
27 | execute(): void { |
||
28 | this.model[this.action](this.data); |
||
29 | this.callback(); |
||
30 | } |
||
31 | } |