js/ServiceMethod.js
function (statusCode, data, plugins, ioArgs) {
                var isList = this.reader.isListResponse(this.name),
                //TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere
                    returnType = this.reader.getResponseSchema(this.name).type || "any", //this could fail if there is no "returns" block on the method
                    payload,
                    that = this,
                    intermediate,
                    successfulResponsePattern = '(2|3)\\d\\d';

                //only auto-process responses if not JSONSchema "null" primitive type
                if (returnType && returnType !== "null") {
                    if (typeof (data) === "object") {
                        //first we apply any global response plugins to the raw data
                        //warning: if the plugin doesn't write it back out with the correct payload name,
                        //it will cause an issue below
                        util.executePluginChain(plugins.response, function (plugin) {
                            // filter plugins on statusPattern
                            var statusPattern = plugin.statusPattern || successfulResponsePattern,
                                regex = new RegExp(statusPattern);
                            if (regex.test(statusCode)) {
                                intermediate = plugin.fn.call(plugin.scope || plugin, data, that, ioArgs);
                                data = intermediate || data;
                            }
                        });
                    }

                    payload = data;

                    if (this.responsePayloadName && data && data[this.responsePayloadName]) {

                        payload = data[this.responsePayloadName];

                        logger.debug("Extracting payload for [" + this.name + "] from [" + this.payloadName + "] property", payload);
                    }


                    //apply any read plugins supplied, after receiving the server results
                    util.executePluginChain(plugins.read, function (plugin) {
                        // filter plugins on statusPattern
                        var statusPattern = plugin.statusPattern || successfulResponsePattern,
                            regex = new RegExp(statusPattern);
                        if (regex.test(statusCode)) {
                            if (isList) {
                                payload.some(function (item, idx) {
                                    intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
                                    payload[idx] = intermediate || payload[idx];
                                }, that);
                            } else {
                                intermediate = plugin.fn.call(plugin.scope || plugin, payload, that);
                                payload = intermediate || payload;
                            }
                        }
                    });

                }


                this.data = payload; //hold on to a copy for future use (could be undefined of course)

                return payload;
            }
function (statusCode, data, plugins, ioArgs) {
                var isList = this.reader.isListResponse(this.name),
                //TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere
                    returnType = this.reader.getResponseSchema(this.name).type || "any", //this could fail if there is no "returns" block on the method
                    payload,
                    that = this,
                    intermediate,
                    successfulResponsePattern = '(2|3)\\d\\d';

                //only auto-process responses if not JSONSchema "null" primitive type
                if (returnType && returnType !== "null") {
                    if (typeof (data) === "object") {
                        //first we apply any global response plugins to the raw data
                        //warning: if the plugin doesn't write it back out with the correct payload name,
                        //it will cause an issue below
                        util.executePluginChain(plugins.response, function (plugin) {
                            // filter plugins on statusPattern
                            var statusPattern = plugin.statusPattern || successfulResponsePattern,
                                regex = new RegExp(statusPattern);
                            if (regex.test(statusCode)) {
                                intermediate = plugin.fn.call(plugin.scope || plugin, data, that, ioArgs);
                                data = intermediate || data;
                            }
                        });
                    }

                    payload = data;

                    if (this.responsePayloadName && data && data[this.responsePayloadName]) {

                        payload = data[this.responsePayloadName];

                        logger.debug("Extracting payload for [" + this.name + "] from [" + this.payloadName + "] property", payload);
                    }


                    //apply any read plugins supplied, after receiving the server results
                    util.executePluginChain(plugins.read, function (plugin) {
                        // filter plugins on statusPattern
                        var statusPattern = plugin.statusPattern || successfulResponsePattern,
                            regex = new RegExp(statusPattern);
                        if (regex.test(statusCode)) {
                            if (isList) {
                                payload.some(function (item, idx) {
                                    intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
                                    payload[idx] = intermediate || payload[idx];
                                }, that);
                            } else {
                                intermediate = plugin.fn.call(plugin.scope || plugin, payload, that);
                                payload = intermediate || payload;
                            }
                        }
                    });

                }


                this.data = payload; //hold on to a copy for future use (could be undefined of course)

                return payload;
            }
function ( statusCode , data , plugins , ioArgs ) { var isList = this . reader . isListResponse ( this . name ) , //TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere
 returnType = this . reader . getResponseSchema ( this . name ) . type || "any" , //this could fail if there is no "returns" block on the method
 payload , that = this , intermediate , successfulResponsePattern = '(2|3)\\d\\d' ; //only auto-process responses if not JSONSchema "null" primitive type
 if ( returnType && returnType !== "null" ) { if ( typeof ( data ) === "object" ) { //first we apply any global response plugins to the raw data
 //warning: if the plugin doesn't write it back out with the correct payload name,
 //it will cause an issue below
 util . executePluginChain ( plugins . response , function ( plugin ) { // filter plugins on statusPattern
 var statusPattern = plugin . statusPattern || successfulResponsePattern , regex = new RegExp ( statusPattern ) ; if ( regex . test ( statusCode ) ) { intermediate = plugin . fn . call ( plugin . scope || plugin , data , that , ioArgs ) ; data = intermediate || data ; } } ) ; } payload = data ; if ( this . responsePayloadName && data && data [ this . responsePayloadName ] ) { payload = data [ this . responsePayloadName ] ; logger . debug ( "Extracting payload for [" + this . name + "] from [" + this . payloadName + "] property" , payload ) ; } //apply any read plugins supplied, after receiving the server results
 util . executePluginChain ( plugins . read , function ( plugin ) { // filter plugins on statusPattern
 var statusPattern = plugin . statusPattern || successfulResponsePattern , regex = new RegExp ( statusPattern ) ; if ( regex . test ( statusCode ) ) { if ( isList ) { payload . some ( function ( item , idx ) { intermediate = plugin . fn . call ( plugin . scope || plugin , item , that ) ; payload [ idx ] = intermediate || payload [ idx ] ; } , that ) ; } else { intermediate = plugin . fn . call ( plugin . scope || plugin , payload , that ) ; payload = intermediate || payload ; } } } ) ; } this . data = payload ; //hold on to a copy for future use (could be undefined of course)
 return payload ; }
An internal method used by the handler method generated by invoke to perform plugin processing on the
response data.
@param statusCode {Number} The status code from the request
@param data {Object} The response data returned by the provider
@param plugins {Array of circuits.Plugin} The merged plugins for the invocation
@param ioArgs {Object} The object used to generate the request
An internal method used by the handler method generated by invoke to perform plugin processing on the response data .