Permalink
Browse files

Support modular railway

  • Loading branch information...
1 parent 7d748e9 commit 2b6740052508bf6f6bd2b4ed57f6e34bcf3d31f1 @1602 committed May 2, 2012
Showing with 8 additions and 4 deletions.
  1. +2 −2 index.js
  2. +6 −2 lib/railway.js
View
4 index.js
@@ -5,10 +5,10 @@ exports.Schema = require('./lib/schema').Schema;
exports.AbstractClass = require('./lib/abstract-class').AbstractClass;
exports.Validatable = require('./lib/validatable').Validatable;
-exports.init = function () {
+exports.init = function (root) {
if (!global.railway) return;
railway.orm = exports;
- require('./lib/railway');
+ require('./lib/railway')(root);
};
try {
View
8 lib/railway.js
@@ -4,7 +4,9 @@ var Schema = railway.orm.Schema;
railway.orm._schemas = [];
-var confFile = app.root + '/config/database.json';
+module.exports = function init(root) {
+
+var confFile = (root || app.root) + '/config/database.json';
var config;
if (path.existsSync(confFile)) {
@@ -25,7 +27,7 @@ railway.orm._schemas.push(schema);
context = prepareContext(schema);
// run schema first
-var schemaFile = app.root + '/db/schema.';
+var schemaFile = (root || app.root) + '/db/schema.';
if (path.existsSync(schemaFile + 'js')) {
schemaFile += 'js';
} else if (path.existsSync(schemaFile + 'coffee')) {
@@ -173,3 +175,5 @@ function prepareContext(defSchema, done) {
return r;
}
}
+
+};

0 comments on commit 2b67400

Please sign in to comment.