Skip to content

Commit

Permalink
slight tweak method to make require() refstack
Browse files Browse the repository at this point in the history
  • Loading branch information
zdzolton committed Dec 8, 2010
1 parent 9cbc167 commit acc084b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main.coffee
Expand Up @@ -61,14 +61,14 @@ normalizeFunctionDefinition = (code) ->
createSandbox = (couchFun) ->
sb = {
log: (msg) -> couchFun.log.push msg
require: makeRequireFun makeInitialRefStack couchFun
require: makeRequireFun makeRefStack couchFun.ddoc, couchFun.funPath
}
sb[name] = fun for name, fun of couchFun.overrides
sb

makeInitialRefStack = (couchFun) ->
stack = [couchFun.ddoc]
couchFun.funPath.split('.').forEach (prop) ->
makeRefStack = (ddoc, funPath) ->
stack = [ddoc]
funPath.split('.').forEach (prop) ->
currObj = stack[stack.length - 1]
stack.push currObj[prop]
stack.pop()
Expand Down

0 comments on commit acc084b

Please sign in to comment.