code: function(_hooks, _fun, _args) {
  
        var oldDispatcher = this.$$dsp;
  
        // set new dispatcher
        this.$$dsp = (typeof _hooks === 'function' || !_hooks) ? _hooks : function(_hook, _args, _ctx) {
          if(oldDispatcher) oldDispatcher.apply(null, arguments);
          var extraCb = _hooks[_hook];
          if(extraCb) extraCb.apply(_ctx, _args || EMPTY_ARRAY);
        };
  
        try {
          return _fun.apply(this, _args);
        } finally {
          // reset dispatcher with old value
          this.$$dsp = oldDispatcher;
        }
      }
docs: @memberof CommonApi#
  
  @description Registers hooks to be used only inside the given function (decorated context).
  
  ```javascript
  // special fetch method that sends a special token header.
  restmod.mixin({
  $fetchWithToken: function(_token) {
  return this.$decorate({
  'before-fetch': function(_req) {
  _req.headers = _req.headers || {};
  _req.headers['Token'] = _token;
  }
  ), function() {
  return this.$fetch();
  })
  }
  });
  ```
  
  @param {object|function} _hooks Hook mapping object or hook execution method.
  @param {function} _fun Function to be executed in with decorated context, this function is executed in the callee object context.
  @return {CommonApi} self