o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1373285456.5557382: @value"á{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-05T18:24:48-03:00;FI" length;FiiI" digest;F"%39f0bf0078ad678be2baec8187bc3e77I" source;FI"i(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(); return options.context.redirectBack(); }, 1000); } else { options.context.disableLoader(); 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"%79ab2df872f980ab54f518f61709eabeI"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-05T18:24:48-03:00;FI" digest;F"%c18d2635295d569e598a4e69a424bdf7I" _version;F"%6776f581a4329e299531e1d52aa59832