1 | 'use strict';
|
2 | var DomainError, Fixture, FixtureLoader, debug;
|
3 |
|
4 | DomainError = require('./lib/domain-error');
|
5 |
|
6 | FixtureLoader = require('./fixture-loader');
|
7 |
|
8 | debug = null;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | Fixture = (function() {
|
20 |
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function Fixture(facade, options) {
|
28 | var debugMode, ref;
|
29 | this.facade = facade;
|
30 | if (options == null) {
|
31 | options = {};
|
32 | }
|
33 | debugMode = (ref = options.debug) != null ? ref : !!this.facade.debug;
|
34 | if (debugMode) {
|
35 | require('debug').enable('base-domain:fixture');
|
36 | }
|
37 | debug = require('debug')('base-domain:fixture');
|
38 | this.dirnames = options.dirname != null ? Array.isArray(options.dirname) ? options.dirname : [options.dirname] : [__dirname + '/fixtures'];
|
39 | }
|
40 |
|
41 |
|
42 | |
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | Fixture.prototype.insert = function(names) {
|
52 | return new FixtureLoader(this.facade, this.dirnames).load({
|
53 | async: true,
|
54 | names: names
|
55 | });
|
56 | };
|
57 |
|
58 | return Fixture;
|
59 |
|
60 | })();
|
61 |
|
62 | module.exports = Fixture;
|