Sha256: 9cf2d32a9d94a57b1ed80043ff5998e2a1d76cf5b8d189448586f419694b660a

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

(function(Paloma){

  var Engine = function(config){
    this.factory = config.factory;
    this._request = null;
  };

  Engine.prototype.start = function(){
    var resource = this._request['controller'],
        Controller = this.factory.get(resource);

    if (!Controller){
      return Paloma.warn('Paloma: undefined controller -> ' + resource);
    }

    var controller = new Controller( this._request['params'] ),
        action = this._request['action'],
        params = this._request['params'];

    if (!controller[action]){
      return Paloma.warn('Paloma: undefined action <' + action +
        '> for <' + resource + '> controller');
    }


    Paloma.log('Paloma: Execute ' + resource + '#' + action + ' with');
    Paloma.log(params);

    controller[ this._request['action'] ]();
  };


  Engine.prototype.setRequest = function(resource, action, params){
    this._request = {controller: resource, action: action, params: params};
  };


  Engine.prototype.getRequest = function(key){
    return (!key ? this._request : this._request[key]);
  };


  Paloma.Engine = Engine;

})(window.Paloma);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paloma-4.1.1 vendor/assets/javascripts/paloma/engine.js
paloma-4.1.0 vendor/assets/javascripts/paloma/engine.js