ember-resource 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -4,7 +4,7 @@ A version of the ember-resource javascript library packaged for the asset pipeli
4
4
 
5
5
  Original project is https://github.com/staugaard/ember-resource
6
6
 
7
- Version taken at commit c34fa3bfadfe82481f5a97329734ed4394bb1dc0
7
+ Version taken at commit fb701564a4212eaa0ce3e975190d0d274c553187
8
8
 
9
9
 
10
10
  ## Installation
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module Resource
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -1,8 +1,10 @@
1
- (function(undefined) {
1
+ (function(exports) {
2
2
 
3
3
  var expandSchema, expandSchemaItem, createSchemaProperties,
4
4
  mergeSchemas;
5
5
 
6
+ var Ember = exports.Ember;
7
+
6
8
  function isString(obj) {
7
9
  return !!(obj === '' || (obj && obj !== String && obj.charCodeAt && obj.substr));
8
10
  }
@@ -561,13 +563,12 @@
561
563
  };
562
564
 
563
565
  Ember.Resource.ajax = function(options) {
564
- if(window.stopHere) { debugger }
565
566
  options.dataType = options.dataType || 'json';
566
567
  options.type = options.type || 'GET';
567
568
 
568
569
  if(options.error) {
569
570
  options.error = errorHandlerWithContext(options.error, options);
570
- } else if(Em.Resource.errorHandler) {
571
+ } else if(Ember.Resource.errorHandler) {
571
572
  options.error = errorHandlerWithContext(Ember.Resource.errorHandler, options);
572
573
  }
573
574
 
@@ -646,6 +647,11 @@
646
647
  updateExpiry();
647
648
  });
648
649
 
650
+ Ember.addListener(this, 'didFail', this, function() {
651
+ Ember.set(self, 'resourceState', Ember.Resource.Lifecycle.UNFETCHED);
652
+ updateExpiry();
653
+ });
654
+
649
655
  var resourceStateBeforeSave;
650
656
  Ember.addListener(this, 'willSave', this, function() {
651
657
  resourceStateBeforeSave = Ember.get(self, 'resourceState');
@@ -742,6 +748,7 @@
742
748
  didFetch: function() {},
743
749
  willSave: function() {},
744
750
  didSave: function() {},
751
+ didFail: function() {},
745
752
 
746
753
  fetched: function() {
747
754
  if(!this._fetchDfd) {
@@ -773,12 +780,22 @@
773
780
  }
774
781
  });
775
782
 
776
- this.deferedFetch.always(function() {
783
+ this.deferedFetch.fail(function() {
784
+ self.didFail.call(self);
785
+ Ember.sendEvent(self, 'didFail');
786
+ self.fetched().reject();
787
+ });
788
+
789
+ this.deferedFetch.success(function() {
777
790
  self.didFetch.call(self);
778
791
  Ember.sendEvent(self, 'didFetch');
779
792
  self.fetched().resolve();
780
793
  });
781
794
 
795
+ this.deferedFetch.always(function() {
796
+ self.deferedFetch = null;
797
+ });
798
+
782
799
  return this.deferedFetch;
783
800
  },
784
801
 
@@ -865,7 +882,6 @@
865
882
  Ember.set(this, 'resourceState', Ember.Resource.Lifecycle.DESTROYING);
866
883
  return Ember.Resource.ajax({
867
884
  type: 'DELETE',
868
- resource: this,
869
885
  operation: 'destroy',
870
886
  url: this.resourceURL(),
871
887
  resource: this
@@ -954,6 +970,8 @@
954
970
  this.identityMap.put(id, instance);
955
971
  } else {
956
972
  instance.updateWithApiData(data);
973
+ // ignore incoming resourceState argument
974
+ delete options.resourceState;
957
975
  }
958
976
  } else {
959
977
  instance = this._super.call(this, { data: data });
@@ -1095,6 +1113,7 @@
1095
1113
  this.deferedFetch.always(function() {
1096
1114
  Ember.sendEvent(self, 'didFetch');
1097
1115
  self.fetched().resolve();
1116
+ self.deferredFetch = null;
1098
1117
  });
1099
1118
  return this.deferedFetch;
1100
1119
  },
@@ -1156,7 +1175,7 @@
1156
1175
  toJSON: function() {
1157
1176
  return this.map(function(item) {
1158
1177
  return item.toJSON();
1159
- })
1178
+ });
1160
1179
  }
1161
1180
  }, Ember.Resource.Lifecycle.prototypeMixin);
1162
1181
 
@@ -1190,4 +1209,4 @@
1190
1209
  return instance;
1191
1210
  }
1192
1211
  }, Ember.Resource.Lifecycle.classMixin);
1193
- }());
1212
+ }(this));
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-04-19 00:00:00.000000000 Z
13
+ date: 2012-06-12 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Ember resource asset pipeline
16
16
  email: