universe_compiler 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/universe_compiler/universe/entities.rb +23 -11
- data/lib/universe_compiler/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: c08e67162d84afd5f24048c2ae84f2dea74b74c2
|
4
|
+
data.tar.gz: 9e84f5154592ad5fba0515ad017629efa5a810b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1032c88e42ff577b22aa491f1a0d6f013758f11292e9b8e8e69101ab2df7023e5615457976919007076fa916e00f7a5b1a523fae80d31da516d7cbb7550849
|
7
|
+
data.tar.gz: f8b5e02483e215d7938d0063471ef959bd7d257308e425d721abcca091d7e5c9e1fc85e9922e116b62bc2e4e1625a7fd61f76eedc92305e0e93ea2360014b212
|
@@ -40,15 +40,15 @@ module UniverseCompiler
|
|
40
40
|
if constraints.keys.include? :has_one
|
41
41
|
if e[field_name] == entity
|
42
42
|
e[field_name] = nil
|
43
|
-
impacted_entities[e] ||=
|
44
|
-
impacted_entities[e]
|
43
|
+
impacted_entities[e] ||= []
|
44
|
+
impacted_entities[e] << field_name
|
45
45
|
end
|
46
46
|
end
|
47
47
|
if constraints.keys.include? :has_many
|
48
48
|
if e[field_name].include? entity
|
49
49
|
e[field_name].delete entity
|
50
|
-
impacted_entities[e] ||=
|
51
|
-
impacted_entities[e]
|
50
|
+
impacted_entities[e] ||= []
|
51
|
+
impacted_entities[e] << field_name unless impacted_entities[e].include? field_name
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -56,7 +56,13 @@ module UniverseCompiler
|
|
56
56
|
# Then delete the entity
|
57
57
|
entities.delete entity
|
58
58
|
reindex_all entities
|
59
|
-
impacted_entities.
|
59
|
+
unless impacted_entities.empty?
|
60
|
+
UniverseCompiler.logger.warn "Impacts of '#{entity.as_path}' deletion:"
|
61
|
+
impacted_entities.each do |k, v|
|
62
|
+
UniverseCompiler.logger.warn " - '#{k.as_path}' fields : #{v.join ', '}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
impacted_entities
|
60
66
|
end
|
61
67
|
|
62
68
|
def replace(entity, by)
|
@@ -64,21 +70,21 @@ module UniverseCompiler
|
|
64
70
|
raise UniverseCompiler::Error, "Cannot replace '#{entity.as_path}' with '#{by.as_path}' which is alreadyin the universe!" if entity.universe == by.universe
|
65
71
|
|
66
72
|
# Change references to entity
|
67
|
-
impacted_entities = {
|
73
|
+
impacted_entities = {}
|
68
74
|
entities.each do |e|
|
69
75
|
e.class.fields_constraints.each do |field_name, constraints|
|
70
76
|
if constraints.keys.include? :has_one
|
71
77
|
if e[field_name] == entity
|
72
78
|
e[field_name] = by
|
73
|
-
impacted_entities[e] ||=
|
74
|
-
impacted_entities[e]
|
79
|
+
impacted_entities[e] ||= []
|
80
|
+
impacted_entities[e] << field_name
|
75
81
|
end
|
76
82
|
end
|
77
83
|
if constraints.keys.include? :has_many
|
78
84
|
if e[field_name].map! do |entity_list_item|
|
79
85
|
if (entity == entity_list_item)
|
80
|
-
impacted_entities[e] ||=
|
81
|
-
impacted_entities[e]
|
86
|
+
impacted_entities[e] ||= []
|
87
|
+
impacted_entities[e] << field_name unless impacted_entities[e].include? field_name
|
82
88
|
by
|
83
89
|
else
|
84
90
|
entity_list_item
|
@@ -91,7 +97,13 @@ module UniverseCompiler
|
|
91
97
|
# Then replace the entity
|
92
98
|
entities[entities.index(entity)] = by
|
93
99
|
reindex_all entities
|
94
|
-
impacted_entities.
|
100
|
+
unless impacted_entities.empty?
|
101
|
+
UniverseCompiler.logger.warn "Impacts of '#{entity.as_path}' deletion:"
|
102
|
+
impacted_entities.each do |k, v|
|
103
|
+
UniverseCompiler.logger.warn " - '#{k.as_path}' fields : #{v.join ', '}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
impacted_entities
|
95
107
|
end
|
96
108
|
|
97
109
|
def clear
|