-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement equals method for equivalent ContextClosure objects (#20)
* implement equals method for equivalent ContextClosure objects * implement DependencyOptions::setIgnoreTemplate() & use ContextClosure source template The desire of ignoreTemplate is to prevent over-computing bindings for templates. However, wrapping templates in ContextClosures was preventing us from detecting the template that should be ignored. This resolves the issue by ignoring the base template of the ContextClosure * always wrap templates in ContextClosure when returned from get method and not wrapped already It could be possible for an object to have an unwrapped Template in it that is returned by looking up segemtns, so this shouldn't be an else. Also, wrapping a template in two ContextClosures isn't needed, since the inner ContextClosure is going to be the only one that has an effect. Thus, do check for an existing ContextClosure to avoid direct double wrapping. * more efficient ignore that uses contextClosure.template * use template.equals to handle possible recursive ContextClosure equality checks
- Loading branch information
Showing
4 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
var templates = require('./templates'); | ||
|
||
exports.DependencyOptions = DependencyOptions; | ||
|
||
function DependencyOptions(options) { | ||
this.ignoreTemplate = options && options.ignoreTemplate; | ||
this.setIgnoreTemplate(options && options.ignoreTemplate); | ||
} | ||
DependencyOptions.shouldIgnoreTemplate = function(template, options) { | ||
return (options) ? options.ignoreTemplate === template : false; | ||
}; | ||
DependencyOptions.prototype.setIgnoreTemplate = function(template) { | ||
while (template instanceof templates.ContextClosure) { | ||
template = template.template; | ||
} | ||
this.ignoreTemplate = template; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters