consyncful-tree 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/consyncful/tree/concerns/parent.rb +18 -7
- data/lib/consyncful/tree/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de96606e91d4b2f832cb42429df45f2794cb07526ece0a98e7766384bfabb430
|
4
|
+
data.tar.gz: 32b4749935b9c503e1b6171f09a6b7fe92d1afaec510db1402dc7c377812be8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a8e3e4db80d8b746872e2809715e549def805ab0737bbb3e6d0989e3ea29f0a32428f11e2ddb984055d14d7a2d787eeef966383d8ecebd3a0a2df706f44aebf
|
7
|
+
data.tar.gz: 270dd99f798052d23b6372dc9602c395fe343ee00e9a2aee904a5ec09b731e86d97556d6ac23e179cb0c1651f57a012b2c143cca4d8fac962c34ff12e1c1420b
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -24,19 +24,20 @@ module Consyncful
|
|
24
24
|
|
25
25
|
next if key == "child_models" || child_ids.empty?
|
26
26
|
|
27
|
-
child_ids
|
27
|
+
child_objects = child_ids.map { |id| Consyncful::Base.where(id: id).first }
|
28
|
+
|
29
|
+
child_ids + lookup_child_model_ids_for_list(child_objects)
|
28
30
|
end.flatten.compact
|
29
31
|
end
|
30
32
|
|
31
|
-
def
|
32
|
-
return [] if
|
33
|
-
|
34
|
-
child_ids.map do |id|
|
35
|
-
obj = Consyncful::Base.where(id: id).first
|
33
|
+
def lookup_child_model_ids_for_list(child_objects)
|
34
|
+
return [] if child_objects.empty?
|
36
35
|
|
36
|
+
child_objects.map do |obj|
|
37
37
|
next if obj.nil?
|
38
38
|
|
39
|
-
|
39
|
+
obj_is_parent = classes_with_parent_concern.include?(obj.class)
|
40
|
+
lookup_child_model_ids(context: obj) unless obj_is_parent
|
40
41
|
end.flatten.compact
|
41
42
|
end
|
42
43
|
|
@@ -52,6 +53,16 @@ module Consyncful
|
|
52
53
|
|
53
54
|
private
|
54
55
|
|
56
|
+
# NOTE: I think this break condition is a bit odd.
|
57
|
+
# It works if we think about a "Parent" being a unit that's fields and dependencies will display on
|
58
|
+
# one page; if it isn't content we are going to display with the parent, then we don't care.
|
59
|
+
# It protects us from some kinds of cyclic depencencies.
|
60
|
+
#
|
61
|
+
# However, if we changed our recursive method to instead pass down the children that had been found so far and
|
62
|
+
# only check its children's children if they aren't in the list yet, then we'd be protected from all
|
63
|
+
# cyclic dependencies.
|
64
|
+
# I ran out of time to make that change.
|
65
|
+
|
55
66
|
def classes_with_parent_concern
|
56
67
|
# ObjectSpace lets you interact with garbage collection and traverse alive objects.
|
57
68
|
# This will iterate through all the classes for objects that are alive.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consyncful-tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DigitalNZ
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|