ember-resourceful-rails 0.0.3.1 → 0.0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDZlYjUzYzM2ODUyZDRkODA0ZDBhOGM2NzIyODZkMTU3ZjQ5OWUyOQ==
4
+ MWM2MDNkYTYzYzBiN2ZmMjA0MDU1NTk5ZGJlNDhkNzFiZTg0MjI5Nw==
5
5
  data.tar.gz: !binary |-
6
- MWY3NDgzM2E4MzQ0Y2E2OTYzZmU1ODA2ODI0NDY0NWMxZTdiZTIwOA==
6
+ NjQ0Y2FhM2U0MzBkYmE3NGMzNmIzMTI1ZTZlNWEyODVmZGM4Yjg2Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YTMyOWJkYWUyZDNhYjQ3ZjJjNDhhNDZmOGU3ZjMxYTFiMDNlOWYyNDhhYjA2
10
- NDAzMWZhOWZmOWQxMzBlNjEzMTQ2MThmMzFiMWQ2ODJiYzhkMzkzNmJlMjZm
11
- ODhkMWUyODYzODYzZGJlZmZiMDM1NWRiZWEwMzhjMzM5NTk0OTQ=
9
+ Y2ZiMjMzOTAyOWM0NWYwNjQ5MDRiMTUxOTk2OTRkYWQzNzZiNmRiYTBkZGFk
10
+ YWM0MGEzZmYxMzFjYzQ4ZmRmYTkzOTM2YTczM2YwZTg0NmZlYTY3MDQ3YjE5
11
+ NDYzZGI5ZWQxNTAyYThlOTk2OTgzMTdkMDc0ZjcyOGVlNjllYzg=
12
12
  data.tar.gz: !binary |-
13
- YmI2NmI4MGI0MmE4YTg0NmI3MWY0MjBlZmVkMDAwNjMwOTdjNTVhYTQ5OTIw
14
- MTM5NTYwZmVhMTc2OWNmMzViZWU4ODg4MTMwMWVkMDMxNjQzOGUxMzU3MjQ2
15
- YjhlY2JmOGM0OTIwM2EwZWJhZTVlYTRhYjhkMGRmZDgyYjM4ODc=
13
+ ZDcwMzQ3NzhhNjAyNGFkNDE0ZjdjOWU4ZDc1NjQxNTcyNGFkNTI2NmI1YzAz
14
+ NzRlMzQ2YjNiZWY3NjY3ZTQ0OGYyYTZiNmE5MGRmNjAxODVmZWU5ZTJhMTZl
15
+ YWUyYmI2N2Y2OTExNmQwZGYyOTNjODBkYTk3Y2FiZWRhYjcwNjg=
@@ -1,5 +1,5 @@
1
1
  module EmberResourceful
2
2
  module Rails
3
- VERSION = "0.0.3.1"
3
+ VERSION = "0.0.3.2"
4
4
  end
5
5
  end
@@ -16,6 +16,9 @@ Resourceful.Resource = Ember.Object.extend({
16
16
  isFetching: false,
17
17
  isFetched: false,
18
18
  isSaving: false,
19
+ isDeleting: false,
20
+ isDeleted: false,
21
+
19
22
 
20
23
  init: function() {
21
24
  var _this = this;
@@ -41,7 +44,7 @@ Resourceful.Resource = Ember.Object.extend({
41
44
  },
42
45
 
43
46
  isNew: Ember.computed.equal('id', undefined),
44
-
47
+
45
48
  isDirty: Ember.computed.bool('dirtyProperties.length'),
46
49
 
47
50
  serialize: function() {
@@ -90,7 +93,7 @@ Resourceful.Resource = Ember.Object.extend({
90
93
  return this;
91
94
  },
92
95
 
93
- fetch: function(options) {
96
+ fetchResource: function(options) {
94
97
  var _this = this;
95
98
 
96
99
  this.set('isFetching', true);
@@ -107,12 +110,13 @@ Resourceful.Resource = Ember.Object.extend({
107
110
  .done(function(data, textStatus, jqXHR) {
108
111
  _this.deserialize(data);
109
112
  _this._updatePersistedProperties();
110
-
113
+ })
114
+ .always(function() {
111
115
  _this.set('isFetching', false);
112
116
  });
113
117
  },
114
118
 
115
- save: function(options) {
119
+ saveResource: function(options) {
116
120
  var success, method, _this = this;
117
121
 
118
122
  this.set('isSaving', true);
@@ -140,7 +144,11 @@ Resourceful.Resource = Ember.Object.extend({
140
144
  });
141
145
  },
142
146
 
143
- destroy: function(options) {
147
+ deleteResource: function(options) {
148
+ var _this = this;
149
+
150
+ this.set('isDeleting', true);
151
+
144
152
  if (!options) {
145
153
  options = {};
146
154
  }
@@ -149,7 +157,13 @@ Resourceful.Resource = Ember.Object.extend({
149
157
  options.url = this._resourceUrl();
150
158
  }
151
159
 
152
- return this.resourceAdapter.request('delete', options);
160
+ return this.resourceAdapter.request('delete', options)
161
+ .done(function() {
162
+ _this.set('isDeleted', true);
163
+ })
164
+ .always(function() {
165
+ _this.set('isDeleting', false);
166
+ });
153
167
  },
154
168
 
155
169
  revert: function(key) {
@@ -161,7 +175,7 @@ Resourceful.Resource = Ember.Object.extend({
161
175
  var _this = this;
162
176
 
163
177
  Ember.beginPropertyChanges(this);
164
-
178
+
165
179
  this.dirtyProperties.forEach(function(key) {
166
180
  _this.set(key, _this.persistedProperties[key]);
167
181
  });
@@ -274,7 +288,7 @@ Resourceful.ResourceCollection = Ember.ArrayProxy.extend({
274
288
  if (!resource) {
275
289
  resource = this.resourceClass.create({ id: id });
276
290
 
277
- resource.fetch();
291
+ resource.fetchResource();
278
292
 
279
293
  this.pushObject(resource);
280
294
  }
@@ -291,15 +305,14 @@ Resourceful.ResourceCollection = Ember.ArrayProxy.extend({
291
305
 
292
306
  resource = this.resourceClass.create({ id: id });
293
307
 
294
- return resource.fetch(options)
308
+ return resource.fetchResource(options)
295
309
  .done(function() {
296
310
  _this.pushObject(resource);
297
311
  });
298
312
  },
299
313
 
300
314
  fetchAll: function(options) {
301
- var success,
302
- _this = this;
315
+ var success, _this = this;
303
316
 
304
317
  this.set('isFetching', true);
305
318
 
@@ -313,8 +326,6 @@ Resourceful.ResourceCollection = Ember.ArrayProxy.extend({
313
326
 
314
327
  return this.resourceAdapter.request('read', options)
315
328
  .done(function(data, textStatus, jqXHR) {
316
- _this.content.clear();
317
- _this._resourceIndex = {};
318
329
  _this.loadAll(data);
319
330
  _this.set('isFetching', false);
320
331
  _this.set('isFetched', true);
@@ -336,12 +347,13 @@ Resourceful.ResourceCollection = Ember.ArrayProxy.extend({
336
347
 
337
348
  if (!resource) {
338
349
  resource = this.resourceClass.create();
339
- this.pushObject(resource);
340
350
  }
341
351
 
342
352
  resource.deserialize(json);
343
353
 
344
- resource._updatePersistedProperties();
354
+ if (!this.contains(resource)) {
355
+ this.pushObject(resource);
356
+ }
345
357
  },
346
358
 
347
359
  _resourceUrl: function() {
@@ -389,14 +401,14 @@ Resourceful.ResourceAdapter = Ember.Object.extend({
389
401
 
390
402
  return deferred;
391
403
  },
392
-
404
+
393
405
  buildURI: function(parts) {
394
406
  if (arguments.length > 1) {
395
407
  parts = slice.call(arguments, 0)
396
408
  } else if (typeof parts === 'string') {
397
409
  parts = [parts];
398
410
  }
399
-
411
+
400
412
  return encodeURI((this.namespace + '/' + parts.join('/')).replace(/\/+/g, '/'));
401
413
  },
402
414
 
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.3.1
4
+ version: 0.0.3.2
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-07-18 00:00:00.000000000 Z
11
+ date: 2013-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler