Accept adapter as first argument of Schema constructor

This commit is contained in:
Anatoliy Chakkaev 2013-01-19 20:50:53 +07:00
parent 5efd832881
commit e9b7e89ee9
2 changed files with 6 additions and 2 deletions

View File

@ -59,7 +59,8 @@ function List(data, type, parent) {
var _;
try {
_ = require('underscore');
var underscore = 'underscore';
_ = require(underscore);
} catch (e) {
_ = false;
}

View File

@ -62,7 +62,10 @@ function Schema(name, settings) {
// this is only one initialization entry point of adapter
// this module should define `adapter` member of `this` (schema)
var adapter;
if (name.match(/^\//)) {
if (typeof name === 'object') {
adapter = name;
this.name = adapter.name;
} else if (name.match(/^\//)) {
// try absolute path
adapter = require(name);
} else if (existsSync(__dirname + '/adapters/' + name + '.js')) {