graphiti 1.0.alpha.11 → 1.0.alpha.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphiti.rb +1 -0
- data/lib/graphiti/sideload.rb +2 -4
- data/lib/graphiti/sideload/belongs_to.rb +2 -1
- data/lib/graphiti/sideload/has_many.rb +2 -1
- data/lib/graphiti/sideload/has_one.rb +3 -1
- data/lib/graphiti/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ce517d6401bea528533904e46403edc173ff484
|
4
|
+
data.tar.gz: 2dbb938df50136bcd97d3cab586252c4789e10d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62550f735f9afc8bfcb68261e9a671c8f066245f15931ecbc2497fbe317ec720b6898aa1784daa01c7aed03f39565183c07f43c14d7cd5f0fe4d777e08137ebb
|
7
|
+
data.tar.gz: b006db1dd79aa9f3541ab1a6960468c919d19378b9ff330cbd565c4714bd4d290b0b86778e0f94b51e2101108ad85bda12f80e7ed45576c9b8208286264ad866
|
data/lib/graphiti.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'forwardable'
|
3
3
|
require 'active_support/core_ext/string'
|
4
|
+
require 'active_support/core_ext/enumerable'
|
4
5
|
require 'active_support/core_ext/class/attribute'
|
5
6
|
require 'active_support/core_ext/hash/conversions' # to_xml
|
6
7
|
require 'active_support/concern'
|
data/lib/graphiti/sideload.rb
CHANGED
@@ -173,13 +173,11 @@ module Graphiti
|
|
173
173
|
associated |= relevant_children
|
174
174
|
associate_all(parent, relevant_children)
|
175
175
|
else
|
176
|
-
associated << relevant_children
|
176
|
+
associated << relevant_children if relevant_children
|
177
177
|
associate(parent, relevant_children)
|
178
178
|
end
|
179
179
|
end
|
180
|
-
(
|
181
|
-
children.delete(unassigned)
|
182
|
-
end
|
180
|
+
children.replace(associated)
|
183
181
|
end
|
184
182
|
|
185
183
|
def resolve(parents, query)
|
@@ -24,7 +24,8 @@ class Graphiti::Sideload::BelongsTo < Graphiti::Sideload
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def assign_each(parent, children)
|
27
|
-
|
27
|
+
children_hash = children.index_by(&primary_key)
|
28
|
+
children_hash[parent.send(foreign_key)]
|
28
29
|
end
|
29
30
|
|
30
31
|
def ids_for_parents(parents)
|
@@ -15,6 +15,7 @@ class Graphiti::Sideload::HasMany < Graphiti::Sideload
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def assign_each(parent, children)
|
18
|
-
|
18
|
+
children_hash = children.group_by(&foreign_key)
|
19
|
+
children_hash[parent.send(primary_key)] || []
|
19
20
|
end
|
20
21
|
end
|
@@ -4,6 +4,8 @@ class Graphiti::Sideload::HasOne < Graphiti::Sideload::HasMany
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def assign_each(parent, children)
|
7
|
-
|
7
|
+
children_hash = children.group_by(&foreign_key)
|
8
|
+
result = children_hash[parent.send(primary_key)] || []
|
9
|
+
result[0]
|
8
10
|
end
|
9
11
|
end
|
data/lib/graphiti/version.rb
CHANGED