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 +4 -4
- data/lib/modular_tree/pool.rb +11 -3
- data/lib/modular_tree/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29780afe3a4d0303217b66719daebdc62292f504a4581f19e11bac43c131a92b
|
4
|
+
data.tar.gz: d712c143c16fa5957b03bd4f5a21b8e6e6a48e6ef3c09597d8f25ab3ed596a02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b94f7f70d4777df66e1a4391ac55aa9117e23d8fc389763d3959c7b9650e1572a39bf73e6b05ce522b0371276cb8e7eba024594cc9b688ef36d1a497cfc9a87f
|
7
|
+
data.tar.gz: 75ab4ec990bcf11d1f18b056eb0c1579b4fa58a7af241c7e270641bf4762085eb063428c995c390cd5baecb8df69ec6435e3609f626746a5313ed627fc607e65
|
data/lib/modular_tree/pool.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Tree
|
2
|
-
#
|
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(
|
15
|
+
def initialize(*args)
|
13
16
|
super
|
14
|
-
self.class[self.uid
|
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
|
data/lib/modular_tree/version.rb
CHANGED