Skip to content

Commit

Permalink
Fixing issue with action scopes on json grammar for Token
Browse files Browse the repository at this point in the history
  • Loading branch information
elmasse committed May 20, 2014
1 parent 7d80c8a commit fe3f367
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ cocktail.mix({

_parseRules: function (rules) {
var k, v, action;

for (k in rules) {
v = rules[k];
action = this._parseAction(v);
Expand All @@ -73,20 +73,22 @@ cocktail.mix({

if (stmt.length) {
actionFn = function() {
var ret, args, action, what, next, j;
var ret, args, action, what, next, j, scope;
for (i = 0; i < l; i++) {
scope = actionScope;
args = (ret !== undefined) ? [ret] : arguments;
what = stmt[i];
if (what.indexOf('.') !== -1){
next = what.split('.');
for(j in next){
scope = action || actionScope;
action = (action) ? action[next[j]]: actionScope[next[j]];
}
}else {
action = actionScope[what];
}
ret = (typeof action === "function" ) ? action.apply(actionScope, args) : action;

ret = (typeof action === "function" ) ? action.apply(scope, args) : action;
}

return ret;
Expand Down Expand Up @@ -120,10 +122,10 @@ cocktail.mix({
replaced = replaced.replace(new RegExp(exp[i], 'g'), value.source);
}
}
}
}

regex = new RegExp(replaced);

return regex;
},

Expand Down

0 comments on commit fe3f367

Please sign in to comment.