module.exports = function (sails) {
  return function (chunk, context, bodies, params) {
    var errMessage = null;
    var args       = null;
    try {
      args = JSON.parse(params.args.replace(/'/g, '"'));
    } catch (e) {
      errMessage = 'can\'t parse parameters';
      try {
        sails.log.error(errMessage);
      } catch (e) {
        console.error(errMessage);
      }
      return cb();
    }
    var object = context.stack.head;

    params.func.split('.').some(function (property) {
      if (typeof(object[property]) === "function") {
        var result = object[property].apply(object, args);
        chunk.write(result);
        return true;
      } else {
        errMessage = 'your given \'func\' parameter is not function';
        try {
          sails.log.error(errMessage);
        } catch (e) {
          console.error(errMessage);
        }
        object = object[property];
        return false;
      }
    });

    return chunk;
  };
};
@@ -25,16 +25,20 @@
 n (sails
+, cb
 ) %7B%0A  re
@@ -235,177 +235,17 @@
     
-errMessage = 'can%5C't parse parameters';%0A      try %7B%0A        sails.log.error(errMessage);%0A      %7D catch (e) %7B%0A        console.error(errMessage);%0A      %7D%0A      return cb()
+args = %5B%5D
 ;%0A  

add cb to enable fail safe