Permalink
Browse files

Support modular railway

  • Loading branch information...
1 parent 040b728 commit 8fa85931dc9e67c89220f5a736ae17300179ec56 @1602 committed May 2, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/railway_routes.js
View
@@ -386,12 +386,22 @@ Map.prototype.subroutes = function (name, subroutes) {
* map.resources('books');
* });
*/
-Map.prototype.addRoutes = function (path) {
+Map.prototype.addRoutes = function (path, customBridge) {
+ var map = this;
var routes = require(path);
routes = routes.routes || routes;
if (typeof routes !== 'function') {
throw new Error('Routes is not defined in ' + path);
}
- return routes(this);
+ // temporarily change bridge
+ if (customBridge) {
+ bridge = map.bridge;
+ map.bridge = customBridge;
+ }
+ var r = routes(map);
+ if (customBridge) {
+ map.bridge = bridge;
+ }
+ return r;
};

0 comments on commit 8fa8593

Please sign in to comment.