factory-girl
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -356,3 +356,3 @@ /* global window, define */ | ||
var merge = require('lodash.merge'); | ||
var merge = typeof require === 'function' ? require('lodash.merge') : _.merge; | ||
@@ -385,3 +385,3 @@ function copy(obj) { | ||
else if (callback) { | ||
setImmediate ? setImmediate(callback) : setTimeout(callback, 0); | ||
typeof setImmediate === 'function' ? setImmediate(callback) : setTimeout(callback, 0); | ||
} | ||
@@ -388,0 +388,0 @@ } |
@@ -0,1 +1,2 @@ | ||
/* global window, define */ | ||
(function(adapter) { | ||
@@ -2,0 +3,0 @@ if (typeof module !== 'undefined') { |
@@ -6,3 +6,3 @@ { | ||
"author": "Simon Wade", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"keywords": [ | ||
@@ -9,0 +9,0 @@ "factory", |
@@ -43,3 +43,3 @@ # factory-girl | ||
return 'user' + n + '@demo.com'; | ||
}, | ||
}), | ||
// async functions can be used by accepting a callback as an argument | ||
@@ -69,3 +69,3 @@ async: function(callback) { | ||
Alternatively you can create a new factory that specifies options for all of its models: | ||
```javascript | ||
@@ -116,2 +116,6 @@ var builder = factory.withOptions(options); | ||
### Factory#build | ||
Creates a new (unsaved) instance. | ||
```javascript | ||
@@ -124,2 +128,9 @@ factory.build('post', function(err, post) { | ||
}); | ||
``` | ||
### Factory#create | ||
Builds and saves a new instance. | ||
``` | ||
factory.create('post', function(err, post) { | ||
@@ -159,3 +170,3 @@ // post is a saved Post instance | ||
When you have factories that don't use async property functions, you can use `buildSync()`. | ||
When you have factories that don't use async property functions, you can use `buildSync()`. | ||
Be aware that `assoc()` is an async function, so it can't be used with `buildSync()`. | ||
@@ -170,3 +181,3 @@ | ||
Adapters provide [support for different databases and ORMs](https://www.npmjs.org/browse/keyword/factory-girl). | ||
Adapters can be registered for specific models, or as the 'default adapter', which is used for any models for which an adapter has not been specified. | ||
Adapters can be registered for specific models, or as the 'default adapter', which is used for any models for which an adapter has not been specified. | ||
See the adapter docs for usage, but typical usage is: | ||
@@ -178,6 +189,6 @@ | ||
// use the ObjectAdapter (that simply returns raw objects) for the `post` model | ||
factory.setAdapter(factory.ObjectAdapter, 'post'); | ||
factory.setAdapter(new factory.ObjectAdapter(), 'post'); | ||
``` | ||
## Creating new Factories | ||
## Creating new Factories | ||
@@ -189,3 +200,3 @@ You can create multiple factories which have different settings: | ||
var BookshelfAdapter = require('factory-girl-bookshelf').BookshelfAdapter; | ||
anotherFactory.setAdapter(BookshelfAdapter); // use the Bookshelf adapter | ||
anotherFactory.setAdapter(new BookshelfAdapter()); // use the Bookshelf adapter | ||
``` | ||
@@ -210,2 +221,1 @@ | ||
Copyright (c) 2011 Peter Jihoon Kim. This software is licensed under the [MIT License](http://github.com/petejkim/factory-lady/raw/master/LICENSE). | ||
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
126846
973
213