modular_tree 0.7.0 → 0.8.0

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
  SHA256:
3
- metadata.gz: 70c50cd21f7eb027dcb0560bb164268c929860f61e2912dfbb1a0fd1576f5869
4
- data.tar.gz: 120a0efd4e6dda689412e3618267645e4252ba6b24c8949203162a2c0b979fdf
3
+ metadata.gz: 29780afe3a4d0303217b66719daebdc62292f504a4581f19e11bac43c131a92b
4
+ data.tar.gz: d712c143c16fa5957b03bd4f5a21b8e6e6a48e6ef3c09597d8f25ab3ed596a02
5
5
  SHA512:
6
- metadata.gz: 62af79315ea3ec5c46e47b9e8cd1807b0f6dd33ee914d1a12b37cf8e0006bd2a2be6381e033e1883da88884bcae2e4ffb5a4e66b4d3ca3026d09721ba4e5c9d0
7
- data.tar.gz: 12a75c54c67fd37c920ec4c663cd6199038c713c86d79f14a11143432f79ab1621115e0af7a1266dfecb8a56e5c073d8bf5e30b485e17af21accf840c78f7b4c
6
+ metadata.gz: b94f7f70d4777df66e1a4391ac55aa9117e23d8fc389763d3959c7b9650e1572a39bf73e6b05ce522b0371276cb8e7eba024594cc9b688ef36d1a497cfc9a87f
7
+ data.tar.gz: 75ab4ec990bcf11d1f18b056eb0c1579b4fa58a7af241c7e270641bf4762085eb063428c995c390cd5baecb8df69ec6435e3609f626746a5313ed627fc607e65
@@ -1,5 +1,8 @@
1
1
  module Tree
2
- # For internal trees with a global namespace for nodes
2
+ # A pool assumes objects has a unique identifier
3
+ #
4
+ # Pool adds a @pool class variable to the including class and all of its
5
+ # subclasses
3
6
  module Pool
4
7
  include PathAlgorithms
5
8
 
@@ -9,9 +12,9 @@ module Tree
9
12
  super
10
13
  end
11
14
 
12
- def initialize(_parent)
15
+ def initialize(*args)
13
16
  super
14
- self.class[self.uid] = self
17
+ self.class.send(:[]=, self.uid, self)
15
18
  end
16
19
 
17
20
  module ClassMethods
@@ -22,6 +25,11 @@ module Tree
22
25
  def empty? = @pool.empty?
23
26
  def [](uid) = @pool[uid]
24
27
  def []=(uid, node) @pool[uid] = node end
28
+
29
+ def inherited(subclass)
30
+ subclass.instance_variable_set(:@pool, @pool)
31
+ super
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tree
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modular_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen