ember-resourceful-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzU1Mjk3OWE3ZjIwNTY0YjYwM2I1NDg3NjIxOWE0NzczMzIyM2E3Yg==
4
+ NDYwNzRkNDJmNGVmNjQ4OWNjNjQ5ZWYzMTI3YjcwNjgyMzBiNjllYg==
5
5
  data.tar.gz: !binary |-
6
- ZDY5OWVlN2MyOTViYzdjMDkxM2IzOGVjOGZiNjRhYTdlNTdiMWY0Zg==
6
+ M2VhYWRjZjI3MzMxYTA4ZGM2MTk2OThjZWE2MGJlYjRhNWQ2MjI4NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjFlYTA2MGRjNzJmYjkyYjNhMjg1ZjllOTI1YzE4ZDY5ZDM2YzQ4ZTc1ZTBi
10
- YWU0N2QzYjEwYzU5OTA0YmMwYjAxM2NjYTExOTc0ODczNGVlMjU4YzRhMGJj
11
- YjQ0MmU1MzUwNTc5NjJmNDczMGIwOTcyYjIyZDRhMWZkYmEwYjU=
9
+ Y2RmYTI2ZjkwZTVjNTk0Mjk1NTgxZjdiZDViMWU3N2QzNDRmMWEwOGNlZDkx
10
+ OGJkNjQwNTBiYzczNDE1ZmE1NDU1ZjZkOGNhYzgxZjRjYjAwYTY5MTBiZmI0
11
+ MTQ3ZjRmNjA1N2EwNzBlYjY3OWNhNDE3YjIzYWUyNDZlYzhhNDM=
12
12
  data.tar.gz: !binary |-
13
- NjVkY2E0YjNkNDI2NWVkNWU2ZGQyN2M3MWY0MDFlYmRkYzk0MDk5ZjMyZGNh
14
- NzkyZGRjYWNmMzJlMWYwY2ExM2FhYWUyYTYxYWU0NDc4MzZmMDE4NjIxMGQz
15
- Y2I1OGI3YjBlNzc0NDBiYTM1MmY0YWM0MWRlNTVkYjhhMDJhYjA=
13
+ Mzg4MmZmMDg1NDU1MTE5NDhiODc1ZmM5MTQ4Y2FmZjgzN2ViZDY4ODk3YmI3
14
+ OGI5ODE3ZWU4YmMzMzEyNTEwNjQ0MWFhNWE1NzFhMTQ3NjBhNmNlMThmODc3
15
+ NjYzMGQ4MmRiMjBiNjNhODk4YTY4NjE0ZTlkNWE1OGJjNzMyZWI=
@@ -1,5 +1,5 @@
1
1
  module EmberResourceful
2
2
  module Rails
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,401 +1,412 @@
1
- /*
2
- * Ember Resourceful 0.0.1
3
- *
4
- * Copyright (c) 2012-2013 Dan Martens
5
- * http://danmartens.com
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining
8
- * a copy of this software and associated documentation files (the
9
- * "Software"), to deal in the Software without restriction, including
10
- * without limitation the rights to use, copy, modify, merge, publish,
11
- * distribute, sublicense, and/or sell copies of the Software, and to
12
- * permit persons to whom the Software is furnished to do so, subject to
13
- * the following conditions:
14
- *
15
- * The above copyright notice and this permission notice shall be
16
- * included in all copies or substantial portions of the Software.
17
- *
18
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
- */
1
+ /* Ember Resourceful v0.0.3 */
26
2
 
27
3
  (function() {
28
- window.Resourceful = {};
29
-
30
- Resourceful.Resource = Ember.Object.extend({
31
- resourceAdapter: null,
32
- resourceProperties: null,
33
- resourceUrl: null,
34
- serializers: null,
35
- deserializers: null,
36
-
37
- isFetching: false,
38
- isFetched: false,
39
- isSaving: false,
40
-
41
- init: function() {
42
- var _this = this;
43
-
44
- this.persistedProperties = {};
45
- this.dirtyProperties = [];
46
-
47
- this._super();
48
-
49
- if (this.resourceProperties) {
50
- this.resourceProperties.forEach(function(key) {
51
- _this.addObserver(key, function() {
52
- if (_this.get(key) !== _this.persistedProperties[key]) {
53
- if (!_this.dirtyProperties.contains(key)) {
54
- _this.dirtyProperties.pushObject(key);
55
- }
56
- } else {
57
- _this.dirtyProperties.removeObject(key);
58
- }
59
- });
60
- });
61
- }
62
- },
63
-
64
- isNew: function() {
65
- return this.get('id') === undefined;
66
- }.property('id'),
67
4
 
68
- isDirty: function() {
69
- return this.get('dirtyProperties.length') !== 0;
70
- }.property('dirtyProperties.length'),
5
+ var slice = Array.prototype.slice;
71
6
 
72
- serialize: function() {
73
- var serialized, _this = this;
7
+ window.Resourceful = {};
74
8
 
75
- serialized = {};
9
+ Resourceful.Resource = Ember.Object.extend({
10
+ resourceAdapter: null,
11
+ resourceProperties: null,
12
+ resourceUrl: null,
13
+ serializers: null,
14
+ deserializers: null,
76
15
 
77
- this.resourceProperties.forEach(function(key) {
78
- var _ref;
79
- if ((_ref = _this.serializers) != null ? _ref[key] : void 0) {
80
- serialized[key] = _this.serializers[key].call(this, _this.get(key));
81
- } else {
82
- serialized[key] = _this.get(key);
83
- }
84
- });
85
-
86
- if (this.resourceName) {
87
- var s = {}; s[this.resourceName] = serialized;
88
- return s;
89
- } else {
90
- return serialized;
91
- }
92
- },
16
+ isFetching: false,
17
+ isFetched: false,
18
+ isSaving: false,
93
19
 
94
- deserialize: function(json) {
95
- var key, value, _ref;
20
+ init: function() {
21
+ var _this = this;
96
22
 
97
- Ember.beginPropertyChanges(this);
23
+ this.persistedProperties = {};
24
+ this.dirtyProperties = [];
98
25
 
99
- for (key in json) {
100
- value = json[key];
26
+ this._super();
101
27
 
102
- if ((_ref = this.deserializers) != null ? _ref[key] : void 0) {
103
- value = this.deserializers[key].call(this, value);
104
- }
28
+ if (this.resourceProperties) {
29
+ this.resourceProperties.forEach(function(key) {
30
+ _this.addObserver(key, function() {
31
+ if (_this.get(key) !== _this.persistedProperties[key]) {
32
+ if (!_this.dirtyProperties.contains(key)) {
33
+ _this.dirtyProperties.pushObject(key);
34
+ }
35
+ } else {
36
+ _this.dirtyProperties.removeObject(key);
37
+ }
38
+ });
39
+ });
40
+ }
41
+ },
105
42
 
106
- this.set(key, value);
107
- }
43
+ isNew: Ember.computed.equal('id', undefined),
44
+
45
+ isDirty: Ember.computed.bool('dirtyProperties.length'),
108
46
 
109
- this.set('isFetched', true);
47
+ serialize: function() {
48
+ var serialized, _this = this;
110
49
 
111
- Ember.endPropertyChanges(this);
50
+ serialized = {};
112
51
 
113
- this._updatePersistedProperties();
52
+ this.resourceProperties.forEach(function(key) {
53
+ var _ref;
54
+ if ((_ref = _this.serializers) != null ? _ref[key] : void 0) {
55
+ serialized[key] = _this.serializers[key].call(this, _this.get(key));
56
+ } else {
57
+ serialized[key] = _this.get(key);
58
+ }
59
+ });
114
60
 
115
- return this;
116
- },
61
+ if (this.resourceName) {
62
+ var s = {}; s[this.resourceName] = serialized;
63
+ return s;
64
+ } else {
65
+ return serialized;
66
+ }
67
+ },
117
68
 
118
- fetch: function(options) {
119
- var _this = this;
69
+ deserialize: function(json) {
70
+ var key, value, _ref;
120
71
 
121
- this.set('isFetching', true);
72
+ Ember.beginPropertyChanges(this);
122
73
 
123
- if (!options) {
124
- options = {};
125
- }
74
+ for (key in json) {
75
+ value = json[key];
126
76
 
127
- if (!options.url) {
128
- options.url = this._resourceUrl();
77
+ if ((_ref = this.deserializers) != null ? _ref[key] : void 0) {
78
+ value = this.deserializers[key].call(this, value);
129
79
  }
130
80
 
131
- return this.resourceAdapter.request('read', options)
132
- .done(function(data, textStatus, jqXHR) {
133
- _this.deserialize(data);
134
- _this._updatePersistedProperties();
81
+ this.set(key, value);
82
+ }
135
83
 
136
- _this.set('isFetching', false);
137
- _this.set('isFetched', true);
138
- });
139
- },
84
+ this.set('isFetched', true);
140
85
 
141
- save: function(options) {
142
- var success, method, _this = this;
86
+ Ember.endPropertyChanges(this);
143
87
 
144
- this.set('isSaving', true);
88
+ this._updatePersistedProperties();
145
89
 
146
- if (!options) {
147
- options = {};
148
- }
90
+ return this;
91
+ },
149
92
 
150
- if (!options.url) {
151
- options.url = this._resourceUrl();
152
- }
93
+ fetch: function(options) {
94
+ var _this = this;
153
95
 
154
- if (!options.data) {
155
- options.data = this.serialize();
156
- }
96
+ this.set('isFetching', true);
157
97
 
158
- method = this.get('isNew') ? 'create' : 'update';
98
+ if (!options) {
99
+ options = {};
100
+ }
159
101
 
160
- return this.resourceAdapter.request(method, options)
161
- .done(function(data, textStatus, jqXHR) {
162
- _this.deserialize(data);
163
- _this._updatePersistedProperties();
102
+ if (!options.url) {
103
+ options.url = this._resourceUrl();
104
+ }
164
105
 
165
- _this.set('isFetched', true);
166
- _this.set('isSaving', false);
167
- });
168
- },
106
+ return this.resourceAdapter.request('read', options)
107
+ .done(function(data, textStatus, jqXHR) {
108
+ _this.deserialize(data);
109
+ _this._updatePersistedProperties();
169
110
 
170
- destroy: function(options) {
171
- if (!options) {
172
- options = {};
173
- }
111
+ _this.set('isFetching', false);
112
+ });
113
+ },
174
114
 
175
- if (!options.url) {
176
- options.url = this._resourceUrl();
177
- }
115
+ save: function(options) {
116
+ var success, method, _this = this;
178
117
 
179
- return this.resourceAdapter.request('delete', options);
180
- },
118
+ this.set('isSaving', true);
181
119
 
182
- revert: function(key) {
183
- this.set(key, this.persistedProperties[key]);
184
- this.dirtyProperties.removeObject(key);
185
- },
120
+ if (!options) {
121
+ options = {};
122
+ }
186
123
 
187
- revertAll: function() {
188
- var _this = this;
124
+ if (!options.url) {
125
+ options.url = this._resourceUrl();
126
+ }
189
127
 
190
- Ember.beginPropertyChanges(this);
128
+ if (!options.data) {
129
+ options.data = this.serialize();
130
+ }
191
131
 
192
- this.dirtyProperties.forEach(function(key) {
193
- _this.revert(key);
194
- });
132
+ method = this.get('isNew') ? 'create' : 'update';
195
133
 
196
- this.dirtyProperties.clear();
134
+ return this.resourceAdapter.request(method, options)
135
+ .done(function(data, textStatus, jqXHR) {
136
+ _this.deserialize(data);
137
+ _this._updatePersistedProperties();
197
138
 
198
- Ember.endPropertyChanges(this);
199
- },
139
+ _this.set('isSaving', false);
140
+ });
141
+ },
200
142
 
201
- _updatePersistedProperties: function() {
202
- if (Array.isArray(this.resourceProperties)) {
203
- var persisted, _this = this;
143
+ destroy: function(options) {
144
+ if (!options) {
145
+ options = {};
146
+ }
204
147
 
205
- persisted = {};
148
+ if (!options.url) {
149
+ options.url = this._resourceUrl();
150
+ }
206
151
 
207
- this.resourceProperties.forEach(function(key) {
208
- persisted[key] = _this.get(key);
209
- });
152
+ return this.resourceAdapter.request('delete', options);
153
+ },
210
154
 
211
- this.set('persistedProperties', persisted);
155
+ revert: function(key) {
156
+ this.set(key, this.persistedProperties[key]);
157
+ this.dirtyProperties.removeObject(key);
158
+ },
212
159
 
213
- this.dirtyProperties.clear();
214
- }
215
- },
160
+ revertAll: function() {
161
+ var _this = this;
216
162
 
217
- _resourceUrl: function() {
218
- var url = this.resourceAdapter.namespace + this.constructor.resourceUrl;
163
+ Ember.beginPropertyChanges(this);
164
+
165
+ this.dirtyProperties.forEach(function(key) {
166
+ _this.set(key, _this.persistedProperties[key]);
167
+ });
219
168
 
220
- if (!this.get('isNew')) {
221
- url += '/' + this.get('id');
222
- }
169
+ this.dirtyProperties.clear();
223
170
 
224
- return url;
225
- }
226
- });
171
+ Ember.endPropertyChanges(this);
172
+ },
227
173
 
228
- Resourceful.Resource.reopenClass({
229
- find: function(id) {
230
- if (this.resourceCollectionPath) {
231
- return Ember.get(this.resourceCollectionPath).findById(id);
232
- } else {
233
- throw new Error('You cannot use `find()` without specifying a `resourceCollectionPath` on the Resource\'s prototype!');
234
- }
235
- },
174
+ _updatePersistedProperties: function() {
175
+ if (Array.isArray(this.resourceProperties)) {
176
+ var persisted, _this = this;
236
177
 
237
- all: function() {
238
- var collection;
178
+ persisted = {};
239
179
 
240
- if (this.resourceCollectionPath) {
241
- collection = Ember.get(this.resourceCollectionPath);
180
+ this.resourceProperties.forEach(function(key) {
181
+ persisted[key] = _this.get(key);
182
+ });
242
183
 
243
- if (!collection.get('isFetched')) {
244
- collection.fetchAll();
245
- }
184
+ this.set('persistedProperties', persisted);
246
185
 
247
- return collection.get('content');
248
- } else {
249
- throw new Error('You cannot use `all()` without specifying a `resourceCollectionPath` on the Resource\'s prototype!');
250
- }
186
+ this.dirtyProperties.clear();
251
187
  }
252
- });
188
+ },
253
189
 
254
- Resourceful.ResourceCollection = Ember.ArrayProxy.extend({
255
- resourceClass: null,
256
- resourceAdapter: null,
190
+ _resourceUrl: function() {
191
+ var url = this.resourceAdapter.namespace + this.constructor.resourceUrl;
257
192
 
258
- isFetching: false,
259
- isFetched: false,
260
-
261
- init: function() {
262
- this._super();
263
-
264
- if (!this.get('content')) {
265
- this.set('content', []);
266
- }
267
- },
193
+ if (!this.get('isNew')) {
194
+ url += '/' + this.get('id');
195
+ }
268
196
 
269
- findById: function(id) {
270
- var resource;
197
+ return url;
198
+ }
199
+ });
271
200
 
272
- resource = this.findProperty('id', id);
201
+ Resourceful.Resource.reopenClass({
202
+ find: function(id) {
203
+ if (this.resourceCollectionPath) {
204
+ return Ember.get(this.resourceCollectionPath).findById(id);
205
+ } else {
206
+ throw new Error('You cannot use `find()` without specifying a `resourceCollectionPath` on the Resource\'s prototype!');
207
+ }
208
+ },
273
209
 
274
- if (!resource) {
275
- resource = this.resourceClass.create({ id: id });
210
+ all: function() {
211
+ var collection;
276
212
 
277
- resource.fetch();
213
+ if (this.resourceCollectionPath) {
214
+ collection = Ember.get(this.resourceCollectionPath);
278
215
 
279
- this.pushObject(resource);
216
+ if (!collection.get('isFetched')) {
217
+ collection.fetchAll();
280
218
  }
281
219
 
282
- return resource;
283
- },
220
+ return collection.get('content');
221
+ } else {
222
+ throw new Error('You cannot use `all()` without specifying a `resourceCollectionPath` on the Resource\'s prototype!');
223
+ }
224
+ }
225
+ });
226
+
227
+ Resourceful.ResourceCollection = Ember.ArrayProxy.extend({
228
+ resourceClass: null,
229
+ resourceAdapter: null,
230
+
231
+ isFetching: false,
232
+ isFetched: false,
233
+
234
+ init: function() {
235
+ var _this = this;
236
+
237
+ this._super();
238
+
239
+ this._resourceIndex = {};
240
+
241
+ if (!this.get('content')) {
242
+ this.set('content', []);
243
+ }
244
+
245
+ this.addArrayObserver(Ember.Object.create({
246
+ arrayWillChange: function(observedObj, start, removeCount, addCount) {
247
+ var removed;
248
+
249
+ if (removeCount > 0) {
250
+ observedObj.slice(start, start + removeCount).forEach(function(resource) {
251
+ if (_this._resourceIndex[resource.id]) {
252
+ delete _this._resourceIndex[resource.id];
253
+ }
254
+ });
255
+ }
256
+ },
257
+ arrayDidChange: function(observedObj, start, removeCount, addCount) {
258
+ var added, filtered;
259
+
260
+ if (addCount > 0) {
261
+ observedObj.slice(start, start + addCount).forEach(function(resource) {
262
+ _this._resourceIndex[resource.id] = resource;
263
+ });
264
+ }
265
+ }
266
+ }));
267
+ },
284
268
 
285
- fetch: function(id, options) {
286
- var resource, _this = this;
269
+ findById: function(id) {
270
+ var resource;
287
271
 
288
- if (!options) {
289
- options = {};
290
- }
272
+ resource = this._resourceIndex[id];
291
273
 
274
+ if (!resource) {
292
275
  resource = this.resourceClass.create({ id: id });
293
276
 
294
- return resource.fetch(options)
295
- .done(function() {
296
- _this.pushObject(resource);
297
- });
298
- },
299
-
300
- fetchAll: function(options) {
301
- var success,
302
- _this = this;
277
+ resource.fetch();
303
278
 
304
- this.set('isFetching', true);
279
+ this.pushObject(resource);
280
+ }
305
281
 
306
- if (!options) {
307
- options = {};
308
- }
282
+ return resource;
283
+ },
309
284
 
310
- if (!options.url) {
311
- options.url = this._resourceUrl();
312
- }
285
+ fetch: function(id, options) {
286
+ var resource, _this = this;
313
287
 
314
- return this.resourceAdapter.request('read', options)
315
- .done(function(data, textStatus, jqXHR) {
316
- _this.content.clear();
317
- _this.loadAll(data);
318
- _this.set('isFetching', false);
319
- _this.set('isFetched', true);
320
- });
321
- },
288
+ if (!options) {
289
+ options = {};
290
+ }
322
291
 
323
- loadAll: function(json) {
324
- var _this = this;
292
+ resource = this.resourceClass.create({ id: id });
325
293
 
326
- json.forEach(function(j) {
327
- _this.load(j);
294
+ return resource.fetch(options)
295
+ .done(function() {
296
+ _this.pushObject(resource);
328
297
  });
329
- },
298
+ },
330
299
 
331
- load: function(json) {
332
- var resource;
300
+ fetchAll: function(options) {
301
+ var success,
302
+ _this = this;
333
303
 
334
- resource = this.findProperty('id', json.id);
304
+ this.set('isFetching', true);
335
305
 
336
- if (!resource) {
337
- resource = this.resourceClass.create();
338
- this.pushObject(resource);
339
- }
340
-
341
- resource.deserialize(json);
342
-
343
- resource._updatePersistedProperties();
344
- },
306
+ if (!options) {
307
+ options = {};
308
+ }
345
309
 
346
- _resourceUrl: function() {
347
- return this.resourceAdapter.namespace + this.resourceClass.resourceUrl;
310
+ if (!options.url) {
311
+ options.url = this._resourceUrl();
348
312
  }
349
- });
350
313
 
351
- Resourceful.ResourceAdapter = Ember.Object.extend({
352
- namespace: '',
314
+ return this.resourceAdapter.request('read', options)
315
+ .done(function(data, textStatus, jqXHR) {
316
+ _this.content.clear();
317
+ _this._resourceIndex = {};
318
+ _this.loadAll(data);
319
+ _this.set('isFetching', false);
320
+ _this.set('isFetched', true);
321
+ });
322
+ },
323
+
324
+ loadAll: function(json) {
325
+ var _this = this;
353
326
 
354
- request: function(method, options) {
355
- var crud, deferred, _this = this;
327
+ json.forEach(function(j) {
328
+ _this.load(j);
329
+ });
330
+ },
356
331
 
357
- crud = {
358
- 'create': 'POST',
359
- 'update': 'PUT',
360
- 'read': 'GET',
361
- 'delete': 'DELETE'
362
- };
332
+ load: function(json) {
333
+ var resource;
363
334
 
364
- deferred = $.Deferred();
335
+ resource = this._resourceIndex[id];
365
336
 
366
- if (!options) {
367
- options = {};
368
- }
337
+ if (!resource) {
338
+ resource = this.resourceClass.create();
339
+ this.pushObject(resource);
340
+ }
369
341
 
370
- options.success = function(data, textStatus, jqXHR) {
371
- deferred.resolve(_this.prepareResponse(data), textStatus, jqXHR);
372
- };
342
+ resource.deserialize(json);
373
343
 
374
- options.error = function(jqXHR, textStatus, errorThrown) {
375
- deferred.reject(jqXHR, textStatus, errorThrown);
376
- };
344
+ resource._updatePersistedProperties();
345
+ },
346
+
347
+ _resourceUrl: function() {
348
+ return this.resourceAdapter.namespace + this.resourceClass.resourceUrl;
349
+ }
350
+ });
377
351
 
378
- options = this.prepareRequest(jQuery.extend({
379
- dataType: 'json',
380
- type: crud[method]
381
- }, options));
352
+ Resourceful.ResourceAdapter = Ember.Object.extend({
353
+ namespace: '',
382
354
 
383
- jqXHR = $.ajax(options);
355
+ request: function(method, options) {
356
+ var crud, deferred, jqXHR, _this = this;
384
357
 
385
- ['abort'].forEach(function(method) {
386
- deferred[method] = jqXHR[method];
387
- });
358
+ crud = {
359
+ 'create': 'POST',
360
+ 'update': 'PUT',
361
+ 'read': 'GET',
362
+ 'delete': 'DELETE'
363
+ };
388
364
 
389
- return deferred;
390
- },
365
+ deferred = $.Deferred();
391
366
 
392
- prepareRequest: function(options) {
393
- return options;
394
- },
367
+ if (!options) {
368
+ options = {};
369
+ }
395
370
 
396
- prepareResponse: function(json) {
397
- return json;
371
+ options.success = function(data, textStatus, jqXHR) {
372
+ deferred.resolve(_this.prepareResponse(data), textStatus, jqXHR);
373
+ };
374
+
375
+ options.error = function(jqXHR, textStatus, errorThrown) {
376
+ deferred.reject(jqXHR, textStatus, errorThrown);
377
+ };
378
+
379
+ options = this.prepareRequest(jQuery.extend({
380
+ dataType: 'json',
381
+ type: crud[method]
382
+ }, options));
383
+
384
+ jqXHR = $.ajax(options);
385
+
386
+ ['abort'].forEach(function(method) {
387
+ deferred[method] = jqXHR[method];
388
+ });
389
+
390
+ return deferred;
391
+ },
392
+
393
+ buildURI: function(parts) {
394
+ if (arguments.length > 1) {
395
+ parts = slice.call(arguments, 0)
396
+ } else if (typeof parts === 'string') {
397
+ parts = [parts];
398
398
  }
399
- });
399
+
400
+ return encodeURI((this.namespace + '/' + parts.join('/')).replace(/\/+/g, '/'));
401
+ },
402
+
403
+ prepareRequest: function(options) {
404
+ return options;
405
+ },
406
+
407
+ prepareResponse: function(json) {
408
+ return json;
409
+ }
410
+ });
400
411
 
401
412
  }).call(this);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-resourceful-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-17 00:00:00.000000000 Z
11
+ date: 2013-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler