factory-girl
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -825,3 +825,3 @@ import _slicedToArray from 'babel-runtime/helpers/slicedToArray'; | ||
key: 'extend', | ||
value: function extend(parent, name, initializer) { | ||
value: function extend(parent, name, childInitializer) { | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
@@ -834,3 +834,19 @@ | ||
var Model = options.model || parentFactory.Model; | ||
var factory = this.factories[name] = new Factory(Model, _Object$assign({}, parentFactory.initializer, initializer), options); | ||
var jointInitializer = void 0; | ||
function resolveInitializer(initializer, buildOptions) { | ||
return typeof initializer === 'function' ? initializer(buildOptions) : initializer; | ||
} | ||
if (typeof parentFactory.initializer === 'function' || typeof childInitializer === 'function') { | ||
jointInitializer = function initializer() { | ||
var buildOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return _Object$assign({}, resolveInitializer(parentFactory.initializer, buildOptions), resolveInitializer(childInitializer, buildOptions)); | ||
}; | ||
} else { | ||
jointInitializer = _Object$assign({}, parentFactory.initializer, childInitializer); | ||
} | ||
var factory = this.factories[name] = new Factory(Model, jointInitializer, options); | ||
return factory; | ||
@@ -857,3 +873,3 @@ } | ||
function attrs(_x4, _x5) { | ||
function attrs(_x5, _x6) { | ||
return _ref.apply(this, arguments); | ||
@@ -890,3 +906,3 @@ } | ||
function build(_x7) { | ||
function build(_x8) { | ||
return _ref2.apply(this, arguments); | ||
@@ -924,3 +940,3 @@ } | ||
function create(_x10, _x11) { | ||
function create(_x11, _x12) { | ||
return _ref3.apply(this, arguments); | ||
@@ -965,3 +981,3 @@ } | ||
function buildMany(_x14, _x15, _x16) { | ||
function buildMany(_x15, _x16, _x17) { | ||
return _ref4.apply(this, arguments); | ||
@@ -1001,3 +1017,3 @@ } | ||
function createMany(_x18, _x19, _x20) { | ||
function createMany(_x19, _x20, _x21) { | ||
return _ref5.apply(this, arguments); | ||
@@ -1014,3 +1030,3 @@ } | ||
if (!this.factories[name] && throwError) { | ||
throw new Error('Invalid factory \'' + name + ' requested'); | ||
throw new Error('Invalid factory \'' + name + '\' requested'); | ||
} | ||
@@ -1017,0 +1033,0 @@ return this.factories[name]; |
32
index.js
@@ -831,3 +831,3 @@ 'use strict'; | ||
key: 'extend', | ||
value: function extend(parent, name, initializer) { | ||
value: function extend(parent, name, childInitializer) { | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
@@ -840,3 +840,19 @@ | ||
var Model = options.model || parentFactory.Model; | ||
var factory = this.factories[name] = new Factory(Model, _Object$assign({}, parentFactory.initializer, initializer), options); | ||
var jointInitializer = void 0; | ||
function resolveInitializer(initializer, buildOptions) { | ||
return typeof initializer === 'function' ? initializer(buildOptions) : initializer; | ||
} | ||
if (typeof parentFactory.initializer === 'function' || typeof childInitializer === 'function') { | ||
jointInitializer = function initializer() { | ||
var buildOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return _Object$assign({}, resolveInitializer(parentFactory.initializer, buildOptions), resolveInitializer(childInitializer, buildOptions)); | ||
}; | ||
} else { | ||
jointInitializer = _Object$assign({}, parentFactory.initializer, childInitializer); | ||
} | ||
var factory = this.factories[name] = new Factory(Model, jointInitializer, options); | ||
return factory; | ||
@@ -863,3 +879,3 @@ } | ||
function attrs(_x4, _x5) { | ||
function attrs(_x5, _x6) { | ||
return _ref.apply(this, arguments); | ||
@@ -896,3 +912,3 @@ } | ||
function build(_x7) { | ||
function build(_x8) { | ||
return _ref2.apply(this, arguments); | ||
@@ -930,3 +946,3 @@ } | ||
function create(_x10, _x11) { | ||
function create(_x11, _x12) { | ||
return _ref3.apply(this, arguments); | ||
@@ -971,3 +987,3 @@ } | ||
function buildMany(_x14, _x15, _x16) { | ||
function buildMany(_x15, _x16, _x17) { | ||
return _ref4.apply(this, arguments); | ||
@@ -1007,3 +1023,3 @@ } | ||
function createMany(_x18, _x19, _x20) { | ||
function createMany(_x19, _x20, _x21) { | ||
return _ref5.apply(this, arguments); | ||
@@ -1020,3 +1036,3 @@ } | ||
if (!this.factories[name] && throwError) { | ||
throw new Error('Invalid factory \'' + name + ' requested'); | ||
throw new Error('Invalid factory \'' + name + '\' requested'); | ||
} | ||
@@ -1023,0 +1039,0 @@ return this.factories[name]; |
@@ -831,3 +831,3 @@ (function (global, factory) { | ||
key: 'extend', | ||
value: function extend(parent, name, initializer) { | ||
value: function extend(parent, name, childInitializer) { | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
@@ -840,3 +840,19 @@ | ||
var Model = options.model || parentFactory.Model; | ||
var factory = this.factories[name] = new Factory(Model, _Object$assign({}, parentFactory.initializer, initializer), options); | ||
var jointInitializer = void 0; | ||
function resolveInitializer(initializer, buildOptions) { | ||
return typeof initializer === 'function' ? initializer(buildOptions) : initializer; | ||
} | ||
if (typeof parentFactory.initializer === 'function' || typeof childInitializer === 'function') { | ||
jointInitializer = function initializer() { | ||
var buildOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return _Object$assign({}, resolveInitializer(parentFactory.initializer, buildOptions), resolveInitializer(childInitializer, buildOptions)); | ||
}; | ||
} else { | ||
jointInitializer = _Object$assign({}, parentFactory.initializer, childInitializer); | ||
} | ||
var factory = this.factories[name] = new Factory(Model, jointInitializer, options); | ||
return factory; | ||
@@ -863,3 +879,3 @@ } | ||
function attrs(_x4, _x5) { | ||
function attrs(_x5, _x6) { | ||
return _ref.apply(this, arguments); | ||
@@ -896,3 +912,3 @@ } | ||
function build(_x7) { | ||
function build(_x8) { | ||
return _ref2.apply(this, arguments); | ||
@@ -930,3 +946,3 @@ } | ||
function create(_x10, _x11) { | ||
function create(_x11, _x12) { | ||
return _ref3.apply(this, arguments); | ||
@@ -971,3 +987,3 @@ } | ||
function buildMany(_x14, _x15, _x16) { | ||
function buildMany(_x15, _x16, _x17) { | ||
return _ref4.apply(this, arguments); | ||
@@ -1007,3 +1023,3 @@ } | ||
function createMany(_x18, _x19, _x20) { | ||
function createMany(_x19, _x20, _x21) { | ||
return _ref5.apply(this, arguments); | ||
@@ -1020,3 +1036,3 @@ } | ||
if (!this.factories[name] && throwError) { | ||
throw new Error('Invalid factory \'' + name + ' requested'); | ||
throw new Error('Invalid factory \'' + name + '\' requested'); | ||
} | ||
@@ -1023,0 +1039,0 @@ return this.factories[name]; |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"keywords": [ | ||
@@ -12,0 +12,0 @@ "factory", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
755021
15107