Skip to content

Commit

Permalink
latest rev fixes naming collisions for Ember.Resource (n/a for this e…
Browse files Browse the repository at this point in the history
…xample)
  • Loading branch information
dgeb committed Feb 1, 2012
1 parent 69be7a8 commit ebf99e9
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions app/assets/javascripts/vendor/ember-rest.js
Expand Up @@ -38,12 +38,13 @@ Ember.Resource = Ember.Object.extend({
/**
Duplicate every property from another resource
REQUIRED: `this.properties` (see note above)
REQUIRED: `properties` (see note above)
*/
duplicateProperties: function(source) {
var prop;
for(var i = 0; i < this.properties.length; i++) {
prop = this.properties[i];
var props = this.constructor.prototype.properties,
prop;
for(var i = 0; i < props.length; i++) {
prop = props[i];
this.set(prop, source.get(prop));
}
},
Expand All @@ -53,16 +54,18 @@ Ember.Resource = Ember.Object.extend({
Override this or `serializeProperty` to provide custom serialization
REQUIRED: `this.properties` and `this.name` (see note above)
REQUIRED: `properties` and `name` (see note above)
*/
serialize: function() {
var ret = {},
prop;

ret[this.name] = {};
for(var i = 0; i < this.properties.length; i++) {
prop = this.properties[i];
ret[this.name][prop] = this.serializeProperty(prop);
var name = this.constructor.prototype.name,
props = this.constructor.prototype.properties,
prop,
ret = {};

ret[name] = {};
for(var i = 0; i < props.length; i++) {
prop = props[i];
ret[name][prop] = this.serializeProperty(prop);
}
return ret;
},
Expand Down Expand Up @@ -107,7 +110,7 @@ Ember.Resource = Ember.Object.extend({
If successful, updates this record's id and other properties
by calling `deserialize()` with the data returned.
REQUIRED: `this.properties` and `this.name` (see note above)
REQUIRED: `properties` and `name` (see note above)
*/
save: function() {
var self = this,
Expand Down Expand Up @@ -156,7 +159,7 @@ Ember.Resource = Ember.Object.extend({
undefined for new resources).
*/
_url: function() {
var url = this.url,
var url = this.constructor.prototype.url,
id = this.get('id');

if (id !== undefined)
Expand Down

0 comments on commit ebf99e9

Please sign in to comment.