sti_type_customizable 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sti_type_customizable/version.rb +1 -1
- data/lib/sti_type_customizable.rb +4 -3
- 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: 35e3700e16d39906db475a0ef2adaf33f4fc3f7e
|
4
|
+
data.tar.gz: f3303e2f8751c15c05a6244ebe05da77f0b63ba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69b91dc39393b64629d644450956ee7a6bb019054aa9b02b6446db2fbf86e73f802df5fec81cc97dceba283402526fc5149280b45c89434f04ab43d736580a7e
|
7
|
+
data.tar.gz: 67e5d2fc2ebc65d80448a9ad86614d695475dc08df30478decec479f9cf3f2121972f866b89277806469844958553b461b026d7bdf28cf7f1de3456798bf22a2
|
@@ -7,11 +7,12 @@ module StiTypeCustomizable
|
|
7
7
|
|
8
8
|
included do
|
9
9
|
class_attribute :sti_type_value
|
10
|
+
class_attribute :sti_entities
|
10
11
|
end
|
11
12
|
|
12
13
|
class_methods do
|
13
14
|
def sti_child_classes(classes)
|
14
|
-
|
15
|
+
self::sti_entities ||= begin
|
15
16
|
{}.tap do |entities|
|
16
17
|
classes.each do |klass|
|
17
18
|
raise NotImplementedError unless klass.include? StiTypeCustomizable
|
@@ -23,11 +24,11 @@ module StiTypeCustomizable
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def find_sti_class(type)
|
26
|
-
|
27
|
+
self::sti_entities[type] || self
|
27
28
|
end
|
28
29
|
|
29
30
|
def sti_name
|
30
|
-
|
31
|
+
self::sti_entities.invert[self] || self::sti_type_value
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|