active-model-adapter-source 1.13.6 → 2.0.0
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 +20 -97
- data/package.json +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDY2Y2E1NzQ4Njg1MGJmNDY5NWVkMmNmMjdlODMxMmRiYTYzODBjYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGZkNzBjMWY5YmRkYTI2YzQ3YzRkM2NjMjdhNDQ0NThkNmE3NjlhYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2RlYTYzYmE4MzI3ZGRkYTY2YmI2YWFjZGZkZWY5MWIwZjkwYWIyMmM3Mjgz
|
10
|
+
OWE2NDRlZjQ2OTcwMzY1M2ExODNjOWIyMmE4ODUxN2E3MWZiMjFlZWU3N2Ix
|
11
|
+
MzQ4NTBmYTA0YjJkZmNkNGNhZjA5NTBhOTJhOWVmOGIzMjE2MTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTY3YTE3NjEyMGQxM2YyOTMzN2RhMzI3NDJjZWU0MjNjZDFiYTFlNjkxNjY5
|
14
|
+
Y2EzNzZiNmU2YmM4ZWM4NzE0YmM3MWFlODY1ZGRmNjQ1MWU2NTc3YThlNmY3
|
15
|
+
MjA5MTI3Nzk5N2MyN2E4MjMzYzE1OGU4ODk0Y2Y3OTg3YTJkMzE=
|
@@ -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
|
8
|
+
* @version 2.0.0
|
9
9
|
*/
|
10
10
|
|
11
11
|
(function() {
|
@@ -507,7 +507,7 @@ define('active-model-serializer', ['exports', 'ember-data', 'ember'], function (
|
|
507
507
|
/*
|
508
508
|
Does not serialize hasMany relationships by default.
|
509
509
|
*/
|
510
|
-
serializeHasMany:
|
510
|
+
serializeHasMany: function () {},
|
511
511
|
|
512
512
|
/**
|
513
513
|
Underscores the JSON root keys when serializing.
|
@@ -538,8 +538,6 @@ define('active-model-serializer', ['exports', 'ember-data', 'ember'], function (
|
|
538
538
|
}
|
539
539
|
},
|
540
540
|
|
541
|
-
// EXTRACT
|
542
|
-
|
543
541
|
/**
|
544
542
|
Add extra step to `DS.RESTSerializer.normalize` so links are normalized.
|
545
543
|
If your payload looks like:
|
@@ -594,64 +592,6 @@ define('active-model-serializer', ['exports', 'ember-data', 'ember'], function (
|
|
594
592
|
}
|
595
593
|
},
|
596
594
|
|
597
|
-
/**
|
598
|
-
Normalize the polymorphic type from the JSON.
|
599
|
-
Normalize:
|
600
|
-
```js
|
601
|
-
{
|
602
|
-
id: "1"
|
603
|
-
minion: { type: "evil_minion", id: "12"}
|
604
|
-
}
|
605
|
-
```
|
606
|
-
To:
|
607
|
-
```js
|
608
|
-
{
|
609
|
-
id: "1"
|
610
|
-
minion: { type: "evilMinion", id: "12"}
|
611
|
-
}
|
612
|
-
```
|
613
|
-
@param {Subclass of DS.Model} typeClass
|
614
|
-
@method normalizeRelationships
|
615
|
-
@private
|
616
|
-
*/
|
617
|
-
normalizeRelationships: function (typeClass, hash) {
|
618
|
-
|
619
|
-
if (this.keyForRelationship) {
|
620
|
-
typeClass.eachRelationship(function (key, relationship) {
|
621
|
-
var _this = this;
|
622
|
-
|
623
|
-
var payloadKey, payload;
|
624
|
-
if (relationship.options.polymorphic) {
|
625
|
-
payloadKey = this.keyForAttribute(key, "deserialize");
|
626
|
-
if (!hash.hasOwnProperty(payloadKey)) {
|
627
|
-
return;
|
628
|
-
}
|
629
|
-
payload = hash[payloadKey];
|
630
|
-
|
631
|
-
if (payload && payload.type) {
|
632
|
-
payload.type = this.modelNameFromPayloadKey(payload.type);
|
633
|
-
} else if (payload && relationship.kind === "hasMany") {
|
634
|
-
payload.forEach(function (single) {
|
635
|
-
return single.type = _this.modelNameFromPayloadKey(single.type);
|
636
|
-
});
|
637
|
-
}
|
638
|
-
} else {
|
639
|
-
payloadKey = this.keyForRelationship(key, relationship.kind, "deserialize");
|
640
|
-
if (!hash.hasOwnProperty(payloadKey)) {
|
641
|
-
return;
|
642
|
-
}
|
643
|
-
payload = hash[payloadKey];
|
644
|
-
}
|
645
|
-
|
646
|
-
hash[key] = payload;
|
647
|
-
|
648
|
-
if (key !== payloadKey) {
|
649
|
-
delete hash[payloadKey];
|
650
|
-
}
|
651
|
-
}, this);
|
652
|
-
}
|
653
|
-
},
|
654
|
-
|
655
595
|
extractRelationships: function (modelClass, resourceHash) {
|
656
596
|
modelClass.eachRelationship(function (key, relationshipMeta) {
|
657
597
|
var relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, "deserialize");
|
@@ -687,32 +627,22 @@ define('active-model-serializer', ['exports', 'ember-data', 'ember'], function (
|
|
687
627
|
var hash = resourceHash[polymorphicKey];
|
688
628
|
if (hash !== null && typeof hash === 'object') {
|
689
629
|
if (relationshipMeta.kind === 'belongsTo') {
|
690
|
-
|
691
|
-
var type = hash.type;
|
692
|
-
|
693
|
-
resourceHash[relationshipKey] = { id: id, type: type };
|
630
|
+
resourceHash[relationshipKey] = extractIDAndType(hash);
|
694
631
|
// otherwise hasMany
|
695
|
-
} else {
|
696
|
-
var hashes =
|
697
|
-
|
698
|
-
if (!hashes) {
|
699
|
-
return;
|
700
|
-
}
|
701
|
-
|
702
|
-
// TODO: replace this with map when ActiveModelAdapter branches for Ember Data 2.0
|
703
|
-
var array = [];
|
704
|
-
for (var i = 0, _length = hashes.length; i < _length; i++) {
|
705
|
-
var _hash = hashes[i];
|
706
|
-
var id = _hash.id;
|
707
|
-
var type = _hash.type;
|
708
|
-
|
709
|
-
array.push({ id: id, type: type });
|
710
|
-
}
|
711
|
-
resourceHash[relationshipKey] = array;
|
632
|
+
} else if (hash.length) {
|
633
|
+
var hashes = hash;
|
634
|
+
resourceHash[relationshipKey] = hashes.map(extractIDAndType);
|
712
635
|
}
|
713
636
|
}
|
714
637
|
}
|
715
638
|
|
639
|
+
function extractIDAndType(hash) {
|
640
|
+
var id = hash.id;
|
641
|
+
var type = hash.type;
|
642
|
+
|
643
|
+
return { id: id, type: type };
|
644
|
+
}
|
645
|
+
|
716
646
|
exports["default"] = ActiveModelSerializer;
|
717
647
|
});
|
718
648
|
define('index', ['exports', './active-model-adapter', './active-model-serializer'], function (exports, _activeModelAdapter, _activeModelSerializer) {
|
@@ -723,9 +653,10 @@ define('index', ['exports', './active-model-adapter', './active-model-serializer
|
|
723
653
|
define("initializers/active-model-adapter", ["exports", "active-model-adapter", "active-model-serializer"], function (exports, _activeModelAdapter, _activeModelAdapterActiveModelSerializer) {
|
724
654
|
exports["default"] = {
|
725
655
|
name: 'active-model-adapter',
|
726
|
-
initialize: function (
|
727
|
-
|
728
|
-
|
656
|
+
initialize: function () {
|
657
|
+
var application = arguments[1] || arguments[0];
|
658
|
+
application.register('adapter:-active-model', _activeModelAdapter["default"]);
|
659
|
+
application.register('serializer:-active-model', _activeModelAdapterActiveModelSerializer["default"]);
|
729
660
|
}
|
730
661
|
};
|
731
662
|
});
|
@@ -733,29 +664,21 @@ define('instance-initializers/active-model-adapter', ['exports', 'active-model-a
|
|
733
664
|
exports["default"] = {
|
734
665
|
name: 'active-model-adapter',
|
735
666
|
initialize: function (applicationOrRegistry) {
|
736
|
-
var registry
|
737
|
-
if (applicationOrRegistry.registry
|
667
|
+
var registry;
|
668
|
+
if (applicationOrRegistry.registry) {
|
738
669
|
// initializeStoreService was registered with an
|
739
670
|
// instanceInitializer. The first argument is the application
|
740
671
|
// instance.
|
741
672
|
registry = applicationOrRegistry.registry;
|
742
|
-
container = applicationOrRegistry.container;
|
743
673
|
} else {
|
744
674
|
// initializeStoreService was called by an initializer instead of
|
745
675
|
// an instanceInitializer. The first argument is a registy. This
|
746
676
|
// case allows ED to support Ember pre 1.12
|
747
677
|
registry = applicationOrRegistry;
|
748
|
-
if (registry.container) {
|
749
|
-
// Support Ember 1.10 - 1.11
|
750
|
-
container = registry.container();
|
751
|
-
} else {
|
752
|
-
// Support Ember 1.9
|
753
|
-
container = registry;
|
754
|
-
}
|
755
678
|
}
|
756
679
|
|
757
680
|
registry.register('adapter:-active-model', _activeModelAdapter["default"]);
|
758
|
-
registry.register('serializer:-active-model', _activeModelAdapterActiveModelSerializer["default"]
|
681
|
+
registry.register('serializer:-active-model', _activeModelAdapterActiveModelSerializer["default"]);
|
759
682
|
}
|
760
683
|
};
|
761
684
|
});
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "active-model-adapter",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.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": {
|
@@ -26,7 +26,7 @@
|
|
26
26
|
"broccoli-merge-trees": "^0.2.1",
|
27
27
|
"broccoli-replace": "^0.3.1",
|
28
28
|
"broccoli-stew": "^0.3.2",
|
29
|
-
"ember-cli": "
|
29
|
+
"ember-cli": "^1.13.0",
|
30
30
|
"ember-cli-app-version": "0.3.3",
|
31
31
|
"ember-cli-content-security-policy": "0.4.0",
|
32
32
|
"ember-cli-dependency-checker": "^1.0.0",
|
@@ -35,7 +35,7 @@
|
|
35
35
|
"ember-cli-pretender": "0.4.0",
|
36
36
|
"ember-cli-qunit": "0.3.13",
|
37
37
|
"ember-cli-uglify": "^1.0.1",
|
38
|
-
"ember-data": "
|
38
|
+
"ember-data": "^2.0.0",
|
39
39
|
"ember-disable-prototype-extensions": "^1.0.0",
|
40
40
|
"ember-disable-proxy-controllers": "^1.0.0",
|
41
41
|
"ember-export-application-global": "^1.0.2",
|
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:
|
4
|
+
version: 2.0.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-08-
|
13
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ember-data-source
|