o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374498083.006494: @value"N{I" class:EFI"ProcessedAsset;FI"logical_path;F"(iugu-ux/components/base_resource.jsI" pathname;F"u/Users/patricknegri/Desenvolvimento/iugu-ux/vendor/assets/javascripts/iugu-ux/components/base_resource.js.coffeeI"content_type;FI"application/javascript;FI" mtime;FI"2013-07-10T19:25:36-03:00;FI" length;FiÖI" digest;F"%9c2973979d7f0df5cc25b4b95b68393aI" source;FI"Ö(function() { var _ref, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; window.app.BaseResource = (function(_super) { __extends(BaseResource, _super); function BaseResource() { _ref = BaseResource.__super__.constructor.apply(this, arguments); return _ref; } BaseResource.prototype.virtual_attributes = []; BaseResource.prototype.initialize = function() { _.each(this.relations, function(relation) { if (relation.type === "Many") { this.generateDefaults(relation); this.generateTriggers(relation); this.generateAddFunction(relation); return this.generateRemoveFunction(relation); } }, this); BaseResource.__super__.initialize.apply(this, arguments); return this; }; BaseResource.prototype.generateDefaults = function(relation) { if (!this.get("" + relation.key)) { return this.set("" + relation.key, []); } }; BaseResource.prototype.generateEvent = function(on_event, key, context) { return this.get(key).on(on_event, function() { return this.trigger("change:" + key); }, context); }; BaseResource.prototype.generateTriggers = function(relation) { this.generateEvent('add', relation.key, this); this.generateEvent('remove', relation.key, this); return this.on('sync', function() { this.generateEvent('add', relation.key, this); return this.generateEvent('remove', relation.key, this); }, this); }; BaseResource.prototype.properCasedRelationName = function(key) { return key.substr(0, 1).toUpperCase() + key.substr(1).toLowerCase(); }; BaseResource.prototype.generateAddFunction = function(relation) { return this["addTo" + (this.properCasedRelationName(relation.key))] = function() { return this.get(relation.key).push(new relation.relatedModel); }; }; BaseResource.prototype.generateRemoveFunction = function(relation) { return this["removeFrom" + (this.properCasedRelationName(relation.key))] = function(object) { return this.get(relation.key).destroy(object); }; }; BaseResource.prototype.sync = function(method, model, options) { this.configureAjax(); return Backbone.sync(method, model, options); }; BaseResource.prototype.toJSON = function(options) { return _.omit(_.clone(BaseResource.__super__.toJSON.call(this, options)), this.virtual_attributes); }; BaseResource.prototype.url = function() { var base; base = BaseResource.__super__.url.apply(this, arguments); return base = this.appendLocaleInfo(base); }; BaseResource.prototype.save = function(attributes, options) { if (this.isValid(true)) { return BaseResource.__super__.save.call(this, null, this.handleViewContext(options)); } }; BaseResource.prototype.handleViewContext = function(options) { if (!options.context) { return options; } options.context.enableLoader(); options.wait = true; options.complete = function(jqXHR, textStatus) { if (textStatus !== "success") { return options.context.disableLoader(); } if (options.elastic_delay === true) { return setTimeout(function() { options.context.disableLoader(); if (!options.callbackView) { return options.context.redirectBack(); } }, 1000); } else { options.context.disableLoader(); if (!options.callbackView) { return options.context.redirectBack(); } } }; return options; }; BaseResource.prototype.destroy = function(options) { return BaseResource.__super__.destroy.call(this, this.handleViewContext(options)); }; BaseResource.prototype.configureAjax = function() { return app.ajaxSetup({ headers: { Authorization: $.base64.encode(api_token) } }); }; BaseResource.prototype.appendLocaleInfo = function(uri) { return uri + (uri.indexOf('?') ? '?' : '&') + 'hl=' + encodeURIComponent(i18n.locale); }; return BaseResource; })(Backbone.AssociatedModel); }).call(this); ;TI"dependency_digest;F"%68d26f2ce8cf204f295f17bc29ec55b3I"required_paths;F["u/Users/patricknegri/Desenvolvimento/iugu-ux/vendor/assets/javascripts/iugu-ux/components/base_resource.js.coffeeI"dependency_paths;F[{I" path;F"u/Users/patricknegri/Desenvolvimento/iugu-ux/vendor/assets/javascripts/iugu-ux/components/base_resource.js.coffeeI" mtime;FI"2013-07-10T19:25:36-03:00;FI" digest;F"%f9f1cc9f2450a1e78edf4620f812d7a7I" _version;F"%6776f581a4329e299531e1d52aa59832