wrap the method of the object, method can receive ctx as it's first argument
345527
function wrapObject(obj, path, prefix) {
  const keys = Object.keys(obj);
  const ret = {};
  for (const key of keys) {
    if (is.function(obj[key])) {
      const names = utility.getParamNames(obj[key]);
      if (names[0] === 'next') {
        throw new Error(`controller \`${prefix || ''}${key}\` should not use next as argument from file ${path}`);
      }
      ret[key] = functionToMiddleware(obj[key]);
      ret[key][FULLPATH] = `${path}#${prefix || ''}${key}()`;
    } else if (is.object(obj[key])) {
      ret[key] = wrapObject(obj[key], path, `${prefix || ''}${key}.`);
    }
  }
  return ret;

  function functionToMiddleware(func) {
    const objectControllerMiddleware = async function(...args) {
      if (!this.app.config.controller || !this.app.config.controller.supportParams) {
        args = [ this ];
      }
      return await utils.callFn(func, args, this);
    };
    for (const key in func) {
      objectControllerMiddleware[key] = func[key];
    }
    return objectControllerMiddleware;
  }
}
1304996
function wrapArguments(trace, clientState, hooks) {
  //wrap any callbacks found in the arguments
  var args = trace.args;
  var handler = clientState.rules.handleArgs(trace.funInfo.name);
  if (handler) {
    handler(trace, clientState);
  }
  for (var i = args.length - 1; i >= 0; i--) {
    var a = args[i];
    if (util.isFunction(a) && !a.__concurix_blacklisted) {
      var callbackState = {
        modInfo: clientState.modInfo,
        rules: clientState.rules,
        callbackOf: trace
      };

      if (wrap.isWrapper(args[i])) {
        args[i].__concurix_proxy_state__
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      else {
        args[i] = wrap(a)
          .before(hooks.beforeHook)
          .after(hooks.afterHook)
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      trace.origFunctionArguments = trace.origFunctionArguments || [];
      trace.origFunctionArguments.push(a);
    }
  }
}
481986
function wrapAsync() {
    // Traverse async methods
    for (var fn in async) {
        // Promisify the method
        async[fn] = wrapAsyncMethod(async[fn], async);
    }

    // Return co-friendly async object
    return async;
}
709886
function wrapQueryMethod(fn, ctx) {
    return function() {
        // Obtain function arguments
        var args = [].slice.call(arguments);
        
        // Return a thunkified function that receives a done callback
        return function(done) {
            // Add a custom callback to provided args
            args.push(function(err, result) {
                // Query failed?
                if (err) {
                    return done(err);
                }

                // Query succeeded
                done(null, result);
            });

            // Execute the query
            fn.apply(ctx, args);
        };
    };
}
1284829
function wrapAsyncMethod(fn, ctx) {
    return function() {
        // Obtain function arguments
        var args = [].slice.call(arguments);

        // Return a thunkified function that receives a done callback
        return new Promise(function(resolve, reject) {
            // Add a custom callback to provided args
            args.push(function(err, result) {
                // Failed?
                if (err) {
                    return reject(err);
                }

                // Success
                resolve(result);
            });

            // Call original function
            fn.apply(ctx, args);
        });
    };
}
664183
function wrap(factory) {
  var out = {};

  methods.forEach(function (method) {
    out[method] = function () {
      var test = factory[method].apply(factory, arguments);
      test.then = createPromiseMethod("then");
      test.catch = createPromiseMethod("catch");
      return test;
    };
  });

  return out;
}
424083
def _wrap_public_method(self, attr):
        
        def wrapper(*args, **kwargs):
            return getattr(self.connection, attr)(*args, **kwargs)
        return wrapper
34200
def method_wrapper(m):
    """"""

    if m.is_simple:
        def simple_method(self):
            """TODO: no docstring!"""
            return apply_transform(
                self.__service__, m.output_transform,
                grpc_call(self.__service__, m, unwrap(self)))

        return simple_method

    elif m.input_transform is not None:
        def transform_method(self, *args, **kwargs):
            """TODO: no docstring!"""
            request = m.input_transform(self, *args, **kwargs)
            return apply_transform(
                self.__service__, m.output_transform,
                grpc_call(self.__service__, m, request))

        return transform_method

    elif m.static:
        def static_method(cls, *args, **kwargs):
            """TODO: no docstring!"""
            request = make_static_request(m, *args, **kwargs)
            return apply_transform(
                cls.__stub__(__server__), m.output_transform,
                grpc_call(cls.__stub__(__server__), m, request))

        return static_method

    else:
        def request_method(self, *args, **kwargs):
            """TODO: no docstring!"""
            request = make_request(self, m, *args, **kwargs)
            return apply_transform(
                self.__service__, m.output_transform,
                grpc_call(self.__service__, m, request))

        return request_method
702125
function wrapify(fn, before = noop, after = noop) {
  return function(...args) {
    before.call(this);
    var ret = fn.call(this, ...args);
    after.call(this);
    return ret;
  };
}
635917
def memoize_method(method):
    """"""
    cache = {}

    @functools.wraps(method)
    def wrapper(self, *args, **kwargs):
        """Caching wrapper."""
        key = (args, tuple(sorted(kwargs.items())))
        if key in cache:
            return cache[key]
        else:
            result = method(self, *args, **kwargs)
            cache[key] = result
            return result

    return wrapper
425032
def ensure_contexted(func):
        
        @wraps(func)
        def wrapped(self, *args, **kwargs):
            if self._buf is None:
                raise TypeError("An Evtx object must be used with"
                                " a context (see the `with` statement).")
            else:
                return func(self, *args, **kwargs)
        return wrapped
308106
function wrap(ctx, fn, key) {
    return function() {
        var def = Q.defer(),
            args = _.toArray(arguments);

        args.push(def.makeNodeResolver());
        fn.apply(ctx, args);

        return def.promise;
    }
}
860998
def with_ctx(func=None):
    '''  '''
    if not func:
        return functools.partial(with_ctx)

    @functools.wraps(func)
    def func_with_context(_obj, *args, **kwargs):
        if 'ctx' not in kwargs or kwargs['ctx'] is None:
            # if context is empty, ensure context
            with _obj.ctx() as new_ctx:
                kwargs['ctx'] = new_ctx
                return func(_obj, *args, **kwargs)
        else:
            # if context is available, just call the function
            return func(_obj, *args, **kwargs)

    return func_with_context
324153
def wrapped_object(self, LayoutClass, fields, *args, **kwargs):
        
        if args:
            if isinstance(fields, list):
                fields = tuple(fields)
            else:
                fields = (fields,)

            if LayoutClass in self.args_first:
                arguments = args + fields
            else:
                arguments = fields + args

            return LayoutClass(*arguments, **kwargs)
        else:
            if isinstance(fields, list):
                return LayoutClass(*fields, **kwargs)
            else:
                return LayoutClass(fields, **kwargs)
313579
function bind (obj, method) {
    var fn = obj[method];
    obj[method] = function () {
      fn.apply(obj, arguments);
    };
  }
111526
def _wrap(cls, func):
        

        if isinstance(func, cls):
            return func
        return functools.update_wrapper(cls(func), func)
160510
def wrap_object(func, before, after):
    '''
    
    '''
    def _wrapper(*args, **kwargs):
        before()
        try:
            return func(*args, **kwargs)
        except Exception as e:
            raise e
        finally:
            after()
    return _wrapper