active-model-adapter-source 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/dist/active-model-adapter.js +160 -110
  3. data/package.json +27 -22
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWM1NTBmYjFkZjliMmQxMjM4MjMyNjM5OWM1NWRlZjU0MzRiNzNkMQ==
4
+ ODY5OGU4MGY4MmFjMDYwZTExNWZkM2ZiNmJiZDU4ODI3MDdhNGJjZA==
5
5
  data.tar.gz: !binary |-
6
- NDQ1MzhkNmNmMjk4M2U2NmViN2ZkNjk1NWU2YWRkYTNjMWVmYzhiYQ==
6
+ MjQ0MDk1MTQxMjU0YWRlZThlZTNlODlmYTNlMWQ3ZDJjOWQ5NzBjYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTkwOTUxYmI5ZThiMGI4ZmNkNjc2NGUwNWQ4M2RhNzAyYmM0ZTAwMTEwZDk3
10
- MGVjZDQxMzk5YjhiNDQ4OTgzMjRlNTZiMzgxOTNmMmM2OGU4MjM2YjMyNDJk
11
- ODI4NGI4NmY3Y2I5ZDcwYmI1YzU1NDdkMzEzZjE0YzQyZGMzNzU=
9
+ M2EyZjgyNWY1Mzk2MmI0MTE2ZTk0NWNmODE0MTlkYWM0OWQyNDgzNTNjZjVi
10
+ M2M2ZTQ1OTIxZjI3N2Y3NWEzNDA5NDk2MGE1ZmQ0NjhhMjhhYmI2NzY3YTBj
11
+ YTAzNzVlM2MyNGRmYjFiNjMzNDlkYmUwY2I2Y2U0NmY4YjI0YmM=
12
12
  data.tar.gz: !binary |-
13
- NDlhN2JkNzY2MmFkZWY5OWI3MWQ5MjBjMzE4Zjg1ZWE4YmJhMjNkOGE3NzBi
14
- Zjk0YmQ3OWQ2MmM1YTZhYTFiODQxNTdiMjQ2MDFhNWYzMjM3MzBlZmZhNjg4
15
- Mzg5MzY2YTg1ZGU1YzI2MWMzYTJmOTE3YmY2ZGMyNjQxMjA0MmU=
13
+ M2FjM2U4OGIwMjQ0ZDk3NTdiYWVkYWJhNzQ3YWRiNDg4MzZmOGRjNmZmMDFm
14
+ NThmMzFlNTk0YTI1MmIyODAzYzFhNTJhNTQ3OWIwMDQ0NTY1ZWJkMjNjOWFl
15
+ MWEwYjAwOWU2OWRiYTBkOGQ5ZTU4YTA4NTFkOWMwNGVjZDE0NjE=
@@ -5,53 +5,129 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 2.0.3
8
+ * @version 2.1.0
9
9
  */
10
10
 
11
11
  (function() {
12
12
 
13
- var define, requireModule, require, requirejs;
13
+ var loader, define, requireModule, require, requirejs;
14
+ var global = this;
14
15
 
15
16
  (function() {
17
+ 'use strict';
18
+
19
+ // Save off the original values of these globals, so we can restore them if someone asks us to
20
+ var oldGlobals = {
21
+ loader: loader,
22
+ define: define,
23
+ requireModule: requireModule,
24
+ require: require,
25
+ requirejs: requirejs
26
+ };
27
+
28
+ loader = {
29
+ noConflict: function(aliases) {
30
+ var oldName, newName;
31
+
32
+ for (oldName in aliases) {
33
+ if (aliases.hasOwnProperty(oldName)) {
34
+ if (oldGlobals.hasOwnProperty(oldName)) {
35
+ newName = aliases[oldName];
36
+
37
+ global[newName] = global[oldName];
38
+ global[oldName] = oldGlobals[oldName];
39
+ }
40
+ }
41
+ }
42
+ }
43
+ };
16
44
 
17
45
  var _isArray;
18
46
  if (!Array.isArray) {
19
47
  _isArray = function (x) {
20
- return Object.prototype.toString.call(x) === "[object Array]";
48
+ return Object.prototype.toString.call(x) === '[object Array]';
21
49
  };
22
50
  } else {
23
51
  _isArray = Array.isArray;
24
52
  }
25
53
 
26
- var registry = {}, seen = {};
54
+ var registry = {};
55
+ var seen = {};
27
56
  var FAILED = false;
57
+ var LOADED = true;
28
58
 
29
59
  var uuid = 0;
30
60
 
31
- function tryFinally(tryable, finalizer) {
32
- try {
33
- return tryable();
34
- } finally {
35
- finalizer();
36
- }
37
- }
38
-
39
61
  function unsupportedModule(length) {
40
- throw new Error("an unsupported module was defined, expected `define(name, deps, module)` instead got: `" + length + "` arguments to define`");
62
+ throw new Error('an unsupported module was defined, expected `define(name, deps, module)` instead got: `' +
63
+ length + '` arguments to define`');
41
64
  }
42
65
 
43
66
  var defaultDeps = ['require', 'exports', 'module'];
44
67
 
45
- function Module(name, deps, callback, exports) {
46
- this.id = uuid++;
47
- this.name = name;
48
- this.deps = !deps.length && callback.length ? defaultDeps : deps;
49
- this.exports = exports || { };
50
- this.callback = callback;
51
- this.state = undefined;
68
+ function Module(name, deps, callback) {
69
+ this.id = uuid++;
70
+ this.name = name;
71
+ this.deps = !deps.length && callback.length ? defaultDeps : deps;
72
+ this.module = { exports: {} };
73
+ this.callback = callback;
74
+ this.state = undefined;
52
75
  this._require = undefined;
76
+ this.finalized = false;
77
+ this.hasExportsAsDep = false;
53
78
  }
54
79
 
80
+ Module.prototype.makeDefaultExport = function() {
81
+ var exports = this.module.exports;
82
+ if (exports !== null &&
83
+ (typeof exports === 'object' || typeof exports === 'function') &&
84
+ exports['default'] === undefined) {
85
+ exports['default'] = exports;
86
+ }
87
+ };
88
+
89
+ Module.prototype.exports = function(reifiedDeps) {
90
+ if (this.finalized) {
91
+ return this.module.exports;
92
+ } else {
93
+ var result = this.callback.apply(this, reifiedDeps);
94
+ if (!(this.hasExportsAsDep && result === undefined)) {
95
+ this.module.exports = result;
96
+ }
97
+ this.makeDefaultExport();
98
+ this.finalized = true;
99
+ return this.module.exports;
100
+ }
101
+ };
102
+
103
+ Module.prototype.unsee = function() {
104
+ this.finalized = false;
105
+ this.state = undefined;
106
+ this.module = { exports: {}};
107
+ };
108
+
109
+ Module.prototype.reify = function() {
110
+ var deps = this.deps;
111
+ var length = deps.length;
112
+ var reified = new Array(length);
113
+ var dep;
114
+
115
+ for (var i = 0, l = length; i < l; i++) {
116
+ dep = deps[i];
117
+ if (dep === 'exports') {
118
+ this.hasExportsAsDep = true;
119
+ reified[i] = this.module.exports;
120
+ } else if (dep === 'require') {
121
+ reified[i] = this.makeRequire();
122
+ } else if (dep === 'module') {
123
+ reified[i] = this.module;
124
+ } else {
125
+ reified[i] = findModule(resolve(dep, this.name), this.name).module.exports;
126
+ }
127
+ }
128
+
129
+ return reified;
130
+ };
55
131
 
56
132
  Module.prototype.makeRequire = function() {
57
133
  var name = this.name;
@@ -59,7 +135,14 @@ var define, requireModule, require, requirejs;
59
135
  return this._require || (this._require = function(dep) {
60
136
  return require(resolve(dep, name));
61
137
  });
62
- }
138
+ };
139
+
140
+ Module.prototype.build = function() {
141
+ if (this.state === FAILED) { return; }
142
+ this.state = FAILED;
143
+ this.exports(this.reify());
144
+ this.state = LOADED;
145
+ };
63
146
 
64
147
  define = function(name, deps, callback) {
65
148
  if (arguments.length < 2) {
@@ -87,92 +170,27 @@ var define, requireModule, require, requirejs;
87
170
  return new Alias(path);
88
171
  };
89
172
 
90
- function reify(mod, name, seen) {
91
- var deps = mod.deps;
92
- var length = deps.length;
93
- var reified = new Array(length);
94
- var dep;
95
- // TODO: new Module
96
- // TODO: seen refactor
97
- var module = { };
98
-
99
- for (var i = 0, l = length; i < l; i++) {
100
- dep = deps[i];
101
- if (dep === 'exports') {
102
- module.exports = reified[i] = seen;
103
- } else if (dep === 'require') {
104
- reified[i] = mod.makeRequire();
105
- } else if (dep === 'module') {
106
- mod.exports = seen;
107
- module = reified[i] = mod;
108
- } else {
109
- reified[i] = requireFrom(resolve(dep, name), name);
110
- }
111
- }
112
-
113
- return {
114
- deps: reified,
115
- module: module
116
- };
117
- }
118
-
119
- function requireFrom(name, origin) {
120
- var mod = registry[name];
121
- if (!mod) {
122
- throw new Error('Could not find module `' + name + '` imported from `' + origin + '`');
123
- }
124
- return require(name);
173
+ function missingModule(name, referrer) {
174
+ throw new Error('Could not find module `' + name + '` imported from `' + referrer + '`');
125
175
  }
126
176
 
127
- function missingModule(name) {
128
- throw new Error('Could not find module ' + name);
129
- }
130
177
  requirejs = require = requireModule = function(name) {
131
- var mod = registry[name];
132
-
133
-
134
- if (mod && mod.callback instanceof Alias) {
135
- mod = registry[mod.callback.name];
136
- }
137
-
138
- if (!mod) { missingModule(name); }
139
-
140
- if (mod.state !== FAILED &&
141
- seen.hasOwnProperty(name)) {
142
- return seen[name];
143
- }
144
-
145
- var reified;
146
- var module;
147
- var loaded = false;
148
-
149
- seen[name] = { }; // placeholder for run-time cycles
178
+ return findModule(name, '(require)').module.exports;
179
+ };
150
180
 
151
- tryFinally(function() {
152
- reified = reify(mod, name, seen[name]);
153
- module = mod.callback.apply(this, reified.deps);
154
- loaded = true;
155
- }, function() {
156
- if (!loaded) {
157
- mod.state = FAILED;
158
- }
159
- });
181
+ function findModule(name, referrer) {
182
+ var mod = registry[name] || registry[name + '/index'];
160
183
 
161
- var obj;
162
- if (module === undefined && reified.module.exports) {
163
- obj = reified.module.exports;
164
- } else {
165
- obj = seen[name] = module;
184
+ while (mod && mod.callback instanceof Alias) {
185
+ name = mod.callback.name;
186
+ mod = registry[name];
166
187
  }
167
188
 
168
- if (obj !== null &&
169
- (typeof obj === 'object' || typeof obj === 'function') &&
170
- obj['default'] === undefined) {
171
- obj['default'] = obj;
172
- }
189
+ if (!mod) { missingModule(name, referrer); }
173
190
 
174
- return (seen[name] = obj);
175
- };
191
+ mod.build();
192
+ return mod;
193
+ }
176
194
 
177
195
  function resolve(child, name) {
178
196
  if (child.charAt(0) !== '.') { return child; }
@@ -189,17 +207,22 @@ var define, requireModule, require, requirejs;
189
207
  throw new Error('Cannot access parent module of root');
190
208
  }
191
209
  parentBase.pop();
192
- } else if (part === '.') { continue; }
193
- else { parentBase.push(part); }
210
+ } else if (part === '.') {
211
+ continue;
212
+ } else { parentBase.push(part); }
194
213
  }
195
214
 
196
215
  return parentBase.join('/');
197
216
  }
198
217
 
199
218
  requirejs.entries = requirejs._eak_seen = registry;
200
- requirejs.clear = function(){
219
+ requirejs.unsee = function(moduleName) {
220
+ findModule(moduleName, '(unsee)').unsee();
221
+ };
222
+
223
+ requirejs.clear = function() {
201
224
  requirejs.entries = requirejs._eak_seen = registry = {};
202
- seen = state = {};
225
+ seen = {};
203
226
  };
204
227
  })();
205
228
 
@@ -341,9 +364,11 @@ define('active-model-adapter', ['exports', 'ember', 'ember-data'], function (exp
341
364
  content was not semantically correct or meaningful per the API.
342
365
  For more information on 422 HTTP Error code see 11.2 WebDAV RFC 4918
343
366
  https://tools.ietf.org/html/rfc4918#section-11.2
344
- @method ajaxError
345
- @param {Object} jqXHR
346
- @return error
367
+ @method handleResponse
368
+ @param {Number} status
369
+ @param {Object} headers
370
+ @param {Object} payload
371
+ @return {Object | DS.AdapterError} response
347
372
  */
348
373
  handleResponse: function (status, headers, payload) {
349
374
  if (this.isInvalid(status, headers, payload)) {
@@ -368,6 +393,7 @@ define('active-model-serializer', ['exports', 'ember-data', 'ember'], function (
368
393
  var singularize = _Ember$String.singularize;
369
394
  var classify = _Ember$String.classify;
370
395
  var decamelize = _Ember$String.decamelize;
396
+ var pluralize = _Ember$String.pluralize;
371
397
  var camelize = _Ember$String.camelize;
372
398
  var underscore = _Ember$String.underscore;
373
399
  var RESTSerializer = _emberData["default"].RESTSerializer;
@@ -592,10 +618,28 @@ define('active-model-serializer', ['exports', 'ember-data', 'ember'], function (
592
618
  }
593
619
  },
594
620
 
621
+ /**
622
+ * @private
623
+ */
624
+ _keyForIDLessRelationship: function (key, relationshipType, type) {
625
+ if (relationshipType === 'hasMany') {
626
+ return underscore(pluralize(key));
627
+ } else {
628
+ return underscore(singularize(key));
629
+ }
630
+ },
631
+
595
632
  extractRelationships: function (modelClass, resourceHash) {
596
633
  modelClass.eachRelationship(function (key, relationshipMeta) {
597
634
  var relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, "deserialize");
598
635
 
636
+ var idLessKey = this._keyForIDLessRelationship(key, relationshipMeta.kind, "deserialize");
637
+
638
+ // converts post to post_id, posts to post_ids
639
+ if (resourceHash[idLessKey] && typeof relationshipMeta[relationshipKey] === 'undefined') {
640
+ resourceHash[relationshipKey] = resourceHash[idLessKey];
641
+ }
642
+
599
643
  // prefer the format the AMS gem expects, e.g.:
600
644
  // relationship: {id: id, type: type}
601
645
  if (relationshipMeta.options.polymorphic) {
@@ -640,10 +684,16 @@ define('index', ['exports', './active-model-adapter', './active-model-serializer
640
684
  define("initializers/active-model-adapter", ["exports", "active-model-adapter", "active-model-serializer"], function (exports, _activeModelAdapter, _activeModelAdapterActiveModelSerializer) {
641
685
  exports["default"] = {
642
686
  name: 'active-model-adapter',
643
- initialize: function () {
644
- var application = arguments[1] || arguments[0];
645
- application.register('adapter:-active-model', _activeModelAdapter["default"]);
646
- application.register('serializer:-active-model', _activeModelAdapterActiveModelSerializer["default"]);
687
+ initialize: function (app) {
688
+ if (arguments.length === 1) {
689
+ // support the old registration API
690
+ app.register('adapter:-active-model', _activeModelAdapter["default"]);
691
+ app.register('serializer:-active-model', _activeModelAdapterActiveModelSerializer["default"]);
692
+ } else {
693
+ var registry = app;
694
+ registry.register('adapter:-active-model', _activeModelAdapter["default"]);
695
+ registry.register('serializer:-active-model', _activeModelAdapterActiveModelSerializer["default"]);
696
+ }
647
697
  }
648
698
  };
649
699
  });
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "active-model-adapter",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "repository": "https://github.com/ember-data/active-model-adapter",
5
5
  "description": "The default blueprint for ember-cli addons.",
6
6
  "directories": {
@@ -18,37 +18,42 @@
18
18
  "author": "",
19
19
  "license": "MIT",
20
20
  "devDependencies": {
21
- "broccoli-asset-rev": "^2.0.2",
22
- "broccoli-babel-transpiler": "^5.1.1",
21
+ "broccoli-asset-rev": "^2.4.1",
22
+ "broccoli-babel-transpiler": "^5.5.0",
23
23
  "broccoli-concat": "0.0.13",
24
24
  "broccoli-es3-safe-recast": "^2.0.0",
25
- "broccoli-funnel": "^0.2.3",
26
- "broccoli-merge-trees": "^0.2.1",
27
- "broccoli-replace": "^0.3.1",
28
- "broccoli-stew": "^0.3.2",
29
- "ember-cli": "^1.13.0",
30
- "ember-cli-app-version": "0.3.3",
25
+ "broccoli-funnel": "^1.0.1",
26
+ "broccoli-merge-trees": "^1.1.0",
27
+ "broccoli-replace": "^0.11.0",
28
+ "broccoli-stew": "^1.0.4",
29
+ "ember-cli": "^2.2.0-beta.1",
30
+ "ember-cli-app-version": "^1.0.0",
31
31
  "ember-cli-content-security-policy": "0.4.0",
32
- "ember-cli-dependency-checker": "^1.0.0",
33
- "ember-cli-htmlbars": "0.7.6",
34
- "ember-cli-inject-live-reload": "^1.3.0",
35
- "ember-cli-pretender": "0.4.0",
36
- "ember-cli-qunit": "0.3.13",
37
- "ember-cli-uglify": "^1.0.1",
38
- "ember-data": "^2.0.0",
39
- "ember-disable-prototype-extensions": "^1.0.0",
40
- "ember-disable-proxy-controllers": "^1.0.0",
41
- "ember-export-application-global": "^1.0.2",
42
- "ember-try": "0.0.7",
43
- "ember-watson": "^0.5.7",
32
+ "ember-cli-dependency-checker": "^1.2.0",
33
+ "ember-cli-htmlbars": "^1.0.1",
34
+ "ember-cli-htmlbars-inline-precompile": "^0.3.1",
35
+ "ember-cli-inject-live-reload": "^1.4.0",
36
+ "ember-cli-pretender": "0.5.0",
37
+ "ember-cli-qunit": "^1.1.0",
38
+ "ember-cli-release": "0.2.8",
39
+ "ember-cli-sri": "^1.2.0",
40
+ "ember-cli-uglify": "^1.2.0",
41
+ "ember-data": "^2.2.1",
42
+ "ember-disable-prototype-extensions": "^1.0.1",
43
+ "ember-disable-proxy-controllers": "^1.0.1",
44
+ "ember-export-application-global": "^1.0.5",
45
+ "ember-resolver": "^2.0.3",
46
+ "ember-try": "~0.0.8",
47
+ "ember-watson": "^0.7.0",
44
48
  "github": "^0.2.4",
49
+ "loader.js": "4.0.1",
45
50
  "rsvp": "^3.1.0"
46
51
  },
47
52
  "keywords": [
48
53
  "ember-addon"
49
54
  ],
50
55
  "dependencies": {
51
- "ember-cli-babel": "^5.0.0"
56
+ "ember-cli-babel": "^5.1.6"
52
57
  },
53
58
  "ember-addon": {
54
59
  "configPath": "tests/dummy/config"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-model-adapter-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Terzic
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-30 00:00:00.000000000 Z
13
+ date: 2016-02-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ember-data-source