From bfadd9fce91b1c2fc6e5b7e677b46e5fde9f97df Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 11 Mar 2014 06:46:12 -0400 Subject: [PATCH] Added missing trait docblocks --- lib/Trait.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/Trait.js b/lib/Trait.js index f1f40da..90687d6 100644 --- a/lib/Trait.js +++ b/lib/Trait.js @@ -23,6 +23,15 @@ var AbstractClass = require( __dirname + '/class_abstract' ), ClassBuilder = require( __dirname + '/ClassBuilder' ); +/** + * Trait constructor / base object + * + * The interpretation of the argument list varies by number. Further, + * various trait methods may be used as an alternative to invoking this + * constructor. + * + * @return {Function} trait + */ function Trait() { switch ( arguments.length ) @@ -199,6 +208,18 @@ function _parseProps( name, value, keywords, h ) } +/** + * Implement one or more interfaces + * + * Implementing an interface into a trait has the same effect as it does + * within classes in that it will automatically define abstract methods + * unless a concrete method is provided. Further, the class that the trait + * is mixed into will act as though it implemented the interfaces. + * + * @param {...Function} interfaces interfaces to implement + * + * @return {Object} staged trait object + */ Trait.implement = function() { var ifaces = arguments; @@ -216,6 +237,13 @@ Trait.implement = function() }; +/** + * Determines if the provided value references a trait + * + * @param {*} trait value to check + * + * @return {boolean} whether the provided value references a trait + */ Trait.isTrait = function( trait ) { return !!( trait || {} ).__trait;