o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1361449320.4794939°: @value"³ {I" class:EFI"BundledAsset;FI"logical_path;FI"web-app/managed_request.js;FI" pathname;FI"~/Users/patricknegri/.rvm/gems/ruby-1.9.2-p290/gems/iugu-ux-0.9.2/vendor/assets/javascripts/web-app/managed_request.coffee;FI"content_type;FI"application/javascript;FI" mtime;FI"2013-01-17T19:18:49-02:00;FI" length;FiªI" digest;F"%3117ecdcf27da3a935b35409772c9c64I" source;FI"ª(function() { var ManagedRequest; ManagedRequest = (function() { ManagedRequest.prototype.defaults = { type: "GET", url: "", name: "managedRequest" }; ManagedRequest.prototype.parseResponse = function(jqXHR) { var obj; obj = {}; obj.responseText = jqXHR.responseText; obj.responseStatus = jqXHR.status; try { obj.data = JSON.parse(jqXHR.responseText); } catch (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"%3b87f4d9b0a62a2e9f132fcf67aefed1I" _version;F"%6776f581a4329e299531e1d52aa59832