Skip to content

Commit

Permalink
refactor(metadata): simplifies detection of empy var
Browse files Browse the repository at this point in the history
  • Loading branch information
stalniy committed Mar 6, 2018
1 parent 4fd14e4 commit afe64f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions lib/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ class Metadata {
}

getVar(name) {
if (!this.values.hasOwnProperty(name)) {
if (!this.values.hasOwnProperty(name) && this.defs[name]) {
this.hasValues = true;
if (this.defs[name] instanceof VariableMetadata) {
this.values[name] = this.defs[name].evaluate();
} else {
this.values[name] = undefined;
}
this.values[name] = this.defs[name].evaluate();
}

return this.values[name];
Expand Down
4 changes: 2 additions & 2 deletions spec/interface_examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ sharedExamplesFor('Lazy Vars Interface', function(getVar) {
expect(getVar('staticVar')).to.equal(value);
});

it('returns undefined where there is no definition', () => {
expect(getVar('notDefined')).to.equal(undefined);
it('returns `undefined` where there is no definition', () => {
expect(getVar('notDefined')).to.be.undefined;
});

it('defines "get.variable" and its alias "get.definitionOf" getter builder', function() {
Expand Down

0 comments on commit afe64f2

Please sign in to comment.