/
Factory.ts
35 lines (31 loc) · 1.07 KB
/
Factory.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type Model from '../Model';
import GlobalConfig from '../../Support/GlobalConfig';
import type FactoryHooks from '../../Contracts/FactoryHooks';
import type { ResolvableAttributes } from './FactoryBuilder';
export default class Factory<T extends Model> implements FactoryHooks<T> {
[method: string]: CallableFunction;
/**
* The instance of the randomisation library if set.
*/
public random? = new GlobalConfig().get('randomDataGenerator');
/**
* Define the model's default attributes.
*
* @param {Model} _emptyModel - an empty instance of the target model.
* @param {number} _loopIndex - the index of the current loop.
*
* @return {Attributes}
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public definition(_emptyModel: T, _loopIndex: number): ResolvableAttributes {
return {};
}
/**
* Get the name of this factory class.
*
* @return {string}
*/
public getClassName(): string {
return this.constructor.name;
}
}