o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1383740409.804781: @value"² {I" class:EFI"BundledAsset;FI"logical_path;FI"web-app/managed_request.js;TI" pathname;FI"^/Users/alezonez/Projetos/iugu-ux/vendor/assets/javascripts/web-app/managed_request.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-01-15T15:36:24-02:00;FI" length;FiÉI" digest;F"%ec2a4d5d0b1dc214ddbdcc60b73f18daI" source;FI"É(function() { var ManagedRequest; ManagedRequest = (function() { ManagedRequest.prototype.defaults = { type: "GET", url: "", name: "managedRequest" }; ManagedRequest.prototype.parseResponse = function(jqXHR) { var error, obj; obj = {}; obj.responseText = jqXHR.responseText; obj.responseStatus = jqXHR.status; try { obj.data = JSON.parse(jqXHR.responseText); } catch (_error) { error = _error; obj.data = {}; } return obj; }; function ManagedRequest(options) { this.options = _.extend({}, this.defaults, this.options, options); this.requester = Backbone.ajax; if (this.options.ajax) { this.requester = this.options.ajax; } this.trigger = function() { return debug("NO TRIGGER"); }; if (this.options.context && this.options.context.trigger) { this.trigger = this.options.context.trigger; this.trigger = _.bind(this.options.context.trigger, this.options.context); } _.bindAll(this); } ManagedRequest.prototype.execute = function() { app.ajaxSetup({ headers: { Authorization: $.base64.encode(api_token) } }); return this.requester({ type: this.options.type, url: this.options.url, data: this.options.data, success: this.success, error: this.error, complete: this.complete }); }; ManagedRequest.prototype.success = function(data, textStatus, jqXHR) { if (data.errors) { return this.trigger("" + this.options.name + ":fail", this.parseResponse(jqXHR)); } else { return this.trigger("" + this.options.name + ":done", this.parseResponse(jqXHR)); } }; ManagedRequest.prototype.error = function(jqXHR, textStatus, errorThrown) { return this.trigger("" + this.options.name + ":fail", this.parseResponse(jqXHR)); }; ManagedRequest.prototype.complete = function(jqXHR, textStatus, errorThrown) { return this.trigger("" + this.options.name + ":all", this.parseResponse(jqXHR)); }; return ManagedRequest; })(); this.ManagedRequest = ManagedRequest; }).call(this); ;FI"required_assets_digest;F"%dbda94fac961b558bd126d224ae38da9I" _version;F"%6776f581a4329e299531e1d52aa59832