Skip to content

Commit 7af71b6

Browse files
committed
Refactoring method to check as pseudo annotation values
1 parent 81c6b14 commit 7af71b6

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

lib/cocktail.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,20 @@ cocktail = {
193193

194194
},
195195

196+
/**
197+
* @private
198+
* returns true if the given subject has a pseudo annotation `@as` with the given value.
199+
*/
200+
_isSubjectDefinedAs: function (subject, asType) {
201+
return (subject && subject['@as'] && subject['@as'].toLowerCase() === asType);
202+
},
203+
196204
/**
197205
* @private
198206
* returns true if the given subject is a class definition object.
199207
*/
200208
_isClassDefition: function (subject) {
201-
var isClassDef = (subject && subject['@as'] && subject['@as'].toLowerCase() === 'class'),
209+
var isClassDef = this._isSubjectDefinedAs(subject, 'class'),
202210
definitionProps = ['constructor', '@extends', '@traits', '@requires', '@annotation'],
203211
key;
204212

@@ -219,7 +227,7 @@ cocktail = {
219227
* returns true if the given subject is a module definition object.
220228
*/
221229
_isModuleDefinition: function (subject) {
222-
return (subject && subject['@as'] && subject['@as'].toLowerCase() === 'module');
230+
return this._isSubjectDefinedAs(subject, 'module');
223231
},
224232

225233
/**
@@ -312,6 +320,7 @@ cocktail = {
312320

313321
};
314322

323+
//export module
315324
module.exports = cocktail;
316325

317326
/**
@@ -332,7 +341,7 @@ cocktail._DEFAULT_PROCESSORS = {
332341
'@static' : require('./processor/annotation/Static'),
333342
};
334343

335-
344+
//register processors
336345
cocktail.registerProcessors(cocktail._DEFAULT_PROCESSORS);
337346

338347
/**

0 commit comments

Comments
 (0)