Skip to content

Commit

Permalink
Cleaned up behavior.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanls committed Dec 17, 2011
1 parent e5bbc1f commit bc6a80d
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lib/anode/behavior.js
Expand Up @@ -5,6 +5,18 @@
*
*/

//
// ### function behavior ( [constructorParams...], behaviorSpec )
// #### @constructorPrams {array} things available to the behavior context
// on construction
// #### @behaviorSpec {function|object} the behavior specification, that
// could be a function that will always be executed on any message,
// or an object specifying a pattern string : function pair that will
// match an incoming message to the pattern, and if the pattern is matched
// it will execute the behavior specified in the function
// Returns a behavior constructor that needs to be called with appropriate
// constructor parameters and then passed to the actor creating function
//
var behavior = exports.behavior = function () {

var __args = Array.prototype.slice.call( arguments );
Expand Down Expand Up @@ -85,7 +97,7 @@ var behavior = exports.behavior = function () {

} // for pattern in behavior

} //
} // else behavior is an object

return function () {

Expand Down Expand Up @@ -156,6 +168,17 @@ var behavior = exports.behavior = function () {

}; // behavior

//
// ### function _createMatcher ( args, functionBody )
// #### @args {array} an array of { type, name } pairs represening
// in sequence the expected arguments in an incoming message
// #### @functionBody {function} the behavior to be executed if
// the message matches the pattern specified via @args
// Returns a matcher function that will return true if called with a message
// containing arguments that match @args, or false otherwise
// The behavior to be executed is attached as __body parameter on
// the returned matcher function.
//
var _createMatcher = function ( args, functionBody ) {

var __context = {};
Expand Down

0 comments on commit bc6a80d

Please sign in to comment.