active-model-adapter-source 1.13.3 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/dist/active-model-adapter.js +57 -1
- data/package.json +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Mzg4YTAwNzdhYzQ3ZDUxZDg3OWE2NmFlOWFmNTE5NjdiOWYxYTUyOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjQ0Nzg4Yzc2Yjg4NDY3ZGIxYjJjYmRkMjZkMDI1MmYwZTNjOGQ1Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmZkMWUyOTlmYjM3MGZkZTcwNzI5YzE5OWZhY2IyMGNjOTgyZGE1ZTFjMWYx
|
10
|
+
NDZiNjI4YzhmOTlkNjY3MjYzNmQzZWMxMzNmNDRhZTgwYmY5MGRlZmI4NjRh
|
11
|
+
MjA2ZGZiMjZkZDRiNzAxYjYwOGY0ZjM5ZDM3ODY2ZGMyNWY5NzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjMzYmZkYjI0OWFhMGMxOWI4OGM2MGNmNzU5YTAzMGU2MGNmNzkxOTk4ZmNl
|
14
|
+
ZGU3NWZkNWNmZDg1NzUwY2UwMjJiNDk4N2Q1OWVjNjJjOGMwOGY3N2Q3MTZk
|
15
|
+
NGJkMWNhYTc1ODcxOThlYWNiZGVhMTA1NTI1ZTM1NWQxNzNlNDU=
|
@@ -5,7 +5,7 @@
|
|
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 1.13.
|
8
|
+
* @version 1.13.4
|
9
9
|
*/
|
10
10
|
|
11
11
|
(function() {
|
@@ -647,12 +647,68 @@ define('active-model-serializer', ['exports', 'ember-data', 'ember'], function (
|
|
647
647
|
}, this);
|
648
648
|
}
|
649
649
|
},
|
650
|
+
|
651
|
+
extractRelationships: function (modelClass, resourceHash) {
|
652
|
+
modelClass.eachRelationship(function (key, relationshipMeta) {
|
653
|
+
var relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');
|
654
|
+
|
655
|
+
// prefer the format the AMS gem expects, e.g.:
|
656
|
+
// relationship: {id: id, type: type}
|
657
|
+
if (relationshipMeta.options.polymorphic) {
|
658
|
+
extractPolymorphicRelationships(key, relationshipMeta, resourceHash, relationshipKey);
|
659
|
+
}
|
660
|
+
// If the preferred format is not found, use {relationship_name_id, relationship_name_type}
|
661
|
+
if (resourceHash.hasOwnProperty(relationshipKey) && typeof resourceHash[relationshipKey] !== 'object') {
|
662
|
+
var polymorphicTypeKey = this.keyForRelationship(key) + '_type';
|
663
|
+
if (resourceHash[polymorphicTypeKey] && relationshipMeta.options.polymorphic) {
|
664
|
+
var id = resourceHash[relationshipKey];
|
665
|
+
var type = resourceHash[polymorphicTypeKey];
|
666
|
+
delete resourceHash[polymorphicTypeKey];
|
667
|
+
delete resourceHash[relationshipKey];
|
668
|
+
resourceHash[relationshipKey] = { id: id, type: type };
|
669
|
+
}
|
670
|
+
}
|
671
|
+
}, this);
|
672
|
+
return this._super.apply(this, arguments);
|
673
|
+
},
|
674
|
+
|
650
675
|
modelNameFromPayloadKey: function (key) {
|
651
676
|
var convertedFromRubyModule = singularize(key.replace('::', '/'));
|
652
677
|
return normalizeModelName(convertedFromRubyModule);
|
653
678
|
}
|
654
679
|
});
|
655
680
|
|
681
|
+
function extractPolymorphicRelationships(key, relationshipMeta, resourceHash, relationshipKey) {
|
682
|
+
var polymorphicKey = decamelize(key);
|
683
|
+
if (polymorphicKey in resourceHash && typeof resourceHash[polymorphicKey] === 'object') {
|
684
|
+
if (relationshipMeta.kind === 'belongsTo') {
|
685
|
+
var hash = resourceHash[polymorphicKey];
|
686
|
+
var id = hash.id;
|
687
|
+
var type = hash.type;
|
688
|
+
|
689
|
+
resourceHash[relationshipKey] = { id: id, type: type };
|
690
|
+
// otherwise hasMany
|
691
|
+
} else {
|
692
|
+
var hashes = resourceHash[polymorphicKey];
|
693
|
+
|
694
|
+
if (!hashes) {
|
695
|
+
return;
|
696
|
+
}
|
697
|
+
|
698
|
+
// TODO: replace this with map when ActiveModelAdapter branches for Ember Data 2.0
|
699
|
+
var array = [];
|
700
|
+
for (var i = 0, _length = hashes.length; i < _length; i++) {
|
701
|
+
var hash = hashes[i];
|
702
|
+
var id = hash.id;
|
703
|
+
var type = hash.type;
|
704
|
+
|
705
|
+
array.push({ id: id, type: type });
|
706
|
+
}
|
707
|
+
resourceHash[relationshipKey] = array;
|
708
|
+
}
|
709
|
+
}
|
710
|
+
}
|
711
|
+
|
656
712
|
exports["default"] = ActiveModelSerializer;
|
657
713
|
});
|
658
714
|
define('index', ['exports', './active-model-adapter', './active-model-serializer'], function (exports, _activeModelAdapter, _activeModelSerializer) {
|
data/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "active-model-adapter",
|
3
|
-
"version": "1.13.
|
4
|
-
"repository": "",
|
3
|
+
"version": "1.13.4",
|
4
|
+
"repository": "https://github.com/ember-data/active-model-adapter",
|
5
5
|
"description": "The default blueprint for ember-cli addons.",
|
6
6
|
"directories": {
|
7
7
|
"doc": "doc",
|
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: 1.13.
|
4
|
+
version: 1.13.4
|
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-07-
|
13
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ember-data-source
|