universe_compiler 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 703e444fd84e095b79e09bc5dea6e2a4690950c4
4
- data.tar.gz: ad94bfaacc67708722298fb3e10a4d4988d84975
3
+ metadata.gz: 68f3d590258d656e0fa5e6d432f6311198b9012c
4
+ data.tar.gz: adbcd0dbbe00ec7c6d01ee02783e2f80c93f7957
5
5
  SHA512:
6
- metadata.gz: 916ae17c012bfcb90660c7690e2adc86bde93d7cebdcfb8684635d0d7170dd3d4328f3c9b21f372e1aa2f5e35a972d669602bf2325581acfe478c4427cbd3921
7
- data.tar.gz: 4d4e1acf886009371248702e18eaeac34299e8ddb7a65b3be430b60e91dc686c71ccb0cf59df35405c186729f0979e0417832a839ca12f2137a289ae1a3fd698
6
+ metadata.gz: fe3c6d9693b48a3a0518c265514280aacb0a410cefcca8589bf602e318121d31faf6e7393987414f8500b0522ea8560806b0ce7cba0e4a0cf20bd4de6a09ca31
7
+ data.tar.gz: 6f4dfad75605f90f49cc0057ac68a08509ba82359bacb26328a8ece4c7827e9f8b7f6bd1550b6932a32f2cfb765148e0e6b9cec812d0bee33c5f0ea8af47d621
@@ -34,19 +34,29 @@ module UniverseCompiler
34
34
 
35
35
  def delete(entity)
36
36
  # Remove references to entity
37
+ impacted_entities = {}
37
38
  entities.each do |e|
38
39
  e.class.fields_constraints.each do |field_name, constraints|
39
40
  if constraints.keys.include? :has_one
40
- e[field_name] = nil if e[field_name] == entity
41
+ if e[field_name] == entity
42
+ e[field_name] = nil
43
+ impacted_entities[e] ||= 0
44
+ impacted_entities[e] += 1
45
+ end
41
46
  end
42
47
  if constraints.keys.include? :has_many
43
- e[field_name].delete entity if e[field_name].include? entity
48
+ if e[field_name].include? entity
49
+ e[field_name].delete entity
50
+ impacted_entities[e] ||= 0
51
+ impacted_entities[e] += 1
52
+ end
44
53
  end
45
54
  end
46
55
  end
47
56
  # Then delete the entity
48
57
  entities.delete entity
49
58
  reindex_all entities
59
+ impacted_entities.keys
50
60
  end
51
61
 
52
62
  def replace(entity, by)
@@ -54,14 +64,25 @@ module UniverseCompiler
54
64
  raise UniverseCompiler::Error, "Cannot replace '#{entity.as_path}' with '#{by.as_path}' which is alreadyin the universe!" if entity.universe == by.universe
55
65
 
56
66
  # Change references to entity
67
+ impacted_entities = {by => 1}
57
68
  entities.each do |e|
58
69
  e.class.fields_constraints.each do |field_name, constraints|
59
70
  if constraints.keys.include? :has_one
60
- e[field_name] = by if e[field_name] == entity
71
+ if e[field_name] == entity
72
+ e[field_name] = by
73
+ impacted_entities[e] ||= 0
74
+ impacted_entities[e] += 1
75
+ end
61
76
  end
62
77
  if constraints.keys.include? :has_many
63
78
  if e[field_name].map! do |entity_list_item|
64
- (entity == entity_list_item) ? by : entity_list_item
79
+ if (entity == entity_list_item)
80
+ impacted_entities[e] ||= 0
81
+ impacted_entities[e] += 1
82
+ by
83
+ else
84
+ entity_list_item
85
+ end
65
86
  end
66
87
  end
67
88
  end
@@ -70,6 +91,7 @@ module UniverseCompiler
70
91
  # Then replace the entity
71
92
  entities[entities.index(entity)] = by
72
93
  reindex_all entities
94
+ impacted_entities.keys
73
95
  end
74
96
 
75
97
  def clear
@@ -1,3 +1,3 @@
1
1
  module UniverseCompiler
2
- VERSION = '0.3.4'.freeze
2
+ VERSION = '0.3.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: universe_compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent B.