Aaron,

When I dropped the above into 3 text files and ran them (with Node 0.10), I 
got an error about ENV being undefined, so I changed it to "process.ENV" 
and then got the expected output. I put the two calls to "test()" at the 
end of server.app.js:

var Server = require('./Server'); // the 'Server' class.
> var ServerController = require('./ServerController'); // the 
> 'ServerController' class.
> var ctrl = new ServerController();
> var server = new Server(process.ENV, ctrl);
> server.test(); // Expecting 'Server-level test'
> server.ctrl.test(); // Expecting 'Controller-level test, shadows 
> Server-level');


Personally I would use "util.inherits(ServerController, Server);" instead 
of manually setting the prototype, but under the hood it does the same 
thing, the only difference is that it wires up a ".super_" property for you 
and configures the constructor 
(https://github.com/joyent/node/blob/master/lib/util.js#L632).

Another thing you might be running into (if your code is slightly different 
from what you posted) is cyclical module references 
(http://nodejs.org/api/modules.html#modules_cycles). The best way to deal 
with that is to do "module.exports = ..." immediately after declaring the 
constructor function and before doing anything else, including any 
require()s 
(https://github.com/AmpersandJS/ampersand-state/issues/78#issuecomment-56844756).

-- peter

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/f07d14eb-871d-4e3c-b652-576af8bee062%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to