Skip to content

Commit

Permalink
Elements of code style, oh my :-O
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoguchi committed Feb 29, 2012
1 parent 3fd7755 commit 4293820
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -75,8 +75,8 @@ everyauth
.addRequestMethod('logout', function () {
var req = this;
delete req.session.auth;

}).addRequestGetter('loggedIn', function () {
})
.addRequestGetter('loggedIn', function () {
var req = this;
if (req.session && req.session.auth && req.session.auth.loggedIn) {
return true;
Expand Down
50 changes: 24 additions & 26 deletions lib/modules/everymodule.js
Expand Up @@ -167,20 +167,17 @@ var everyModule = module.exports = {

, submodules: {}

/**
* Creates a new submodule using prototypal
* inheritance
*/
// Creates a new submodule using prototypal inheritance
, submodule: function (name) {
var submodule = Object.create(this, { name: { value: name } })
, self = this;

// So that when we add configurables after
// to the supermodule after the submodule
// creation, we can propagate those configurables
// to the supermodule's submodules
this.submodules[name] = submodule;
submodule.submodules = {};
var self = this
// So that when we add configurables after
// to the supermodule after the submodule
// creation, we can propagate those configurables
// to the supermodule's submodules
, submodule = this.submodules[name] = Object.create(this, {
name: { value: name }
, submodules: { value: {} }
});

this.cloneOnSubmodule.forEach( function (toClone) {
submodule[toClone] = clone(self[toClone]);
Expand All @@ -203,9 +200,8 @@ var everyModule = module.exports = {

, validateSteps: function () {
var seqs = this._stepSequences;
for (var seqName in seqs) {
for (var seqName in seqs)
seqs[seqName].validateSteps();
}
}

// Decorates the app with the routes required of the module
Expand Down Expand Up @@ -234,11 +230,11 @@ var everyModule = module.exports = {
}

/**
* breakTo(sequenceName, arg1, arg2, ...);
* [arg1, arg2, ...] are the arguments passed to
* the `sequence.start(...)` where sequence is the
* sequence with name `sequenceName`
* @param {String} sequenceName
* Function signature:
* breakTo(sequenceName, arg1, arg2, ...);
*
* [arg1, arg2, ...] are the arguments passed to the `sequence.start(...)`
* where sequence is the sequence with the name `sequenceName`
*/
, breakTo: function (sequenceName) {
// TODO Garbage collect the abandoned sequence
Expand All @@ -260,15 +256,17 @@ var everyModule = module.exports = {
everyModule.get = route('get');
everyModule.post = route('post');

// Returns a function used for declaring new route triggered sequences
// associated with the uri route and the http `method`
// @param {String} method is the http method (e.g, 'get', 'post')
function route (method) {
/**
* Returns a function used for declaring new route triggered sequences
* associated with the uri route and the http `method`
* @param {String} httpMethod (e.g, 'get', 'post')
*/
function route (httpMethod) {
return function (alias, description) { /* `this` is `everyModule` */
if (description)
description = routeDescPrefix[method.toLowerCase()] + ' - ' + description;
description = routeDescPrefix[httpMethod.toLowerCase()] + ' - ' + description;
this.configurable(alias, description);
var name = method + ':' + alias;
var name = httpMethod + ':' + alias;
this._currSeq =
this._stepSequences[name] || (this._stepSequences[name] = new RouteTriggeredSequence(name, this));
return this;
Expand Down

0 comments on commit 4293820

Please sign in to comment.