dispatio 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +3 -1
- data/lib/dispatio.rb +9 -5
- 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: 1291fe6d6ec352d090a78afae44e98656c14026566448a039065f7b58cd9cdf2
|
|
4
|
+
data.tar.gz: 4e70a7cfd9125425d432c70d5eeb3df8829163ce19496378db877b9e8e7edbd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08a3866d4918d6124b60399e0657e3e307647635a0105c9ff2ed54cb679eee236854e7e68ef6bee18939997bf7700cbe50fec87120dbe022b9f6c314da57a81f'
|
|
7
|
+
data.tar.gz: eb83b8f0fb6a6609f44e0f21333645269617c55dd952d43e85c6ae3a6800b020db65d606d629f4efc97e4d770472204a7c81d4a5f7e8bba29fc58b52c9c098f8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -19,7 +19,9 @@ class MyClass
|
|
|
19
19
|
|
|
20
20
|
def post(type, msg)
|
|
21
21
|
|
|
22
|
-
(@ptable ||= Dispatio.make_table(self,
|
|
22
|
+
(@ptable ||= Dispatio.make_table(self, '_post').call(type, msg)
|
|
23
|
+
# or, more explicitely
|
|
24
|
+
#(@ptable ||= Dispatio.make_table(self, suffix: '_post').call(type, msg)
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
protected
|
data/lib/dispatio.rb
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
module Dispatio
|
|
3
3
|
|
|
4
|
-
VERSION = '1.2.
|
|
4
|
+
VERSION = '1.2.1'.freeze
|
|
5
5
|
|
|
6
6
|
class << self
|
|
7
7
|
|
|
8
8
|
def make_table(point, prefix_or_opts)
|
|
9
9
|
|
|
10
10
|
opts =
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
case poo = prefix_or_opts
|
|
12
|
+
when /\A_/ then { suffix: poo }
|
|
13
|
+
when String then { prefix: poo }
|
|
14
|
+
else poo; end
|
|
13
15
|
|
|
14
16
|
fail(
|
|
15
17
|
ArgumentError,
|
|
@@ -29,9 +31,11 @@ module Dispatio
|
|
|
29
31
|
.methods
|
|
30
32
|
.inject({}) { |h, m|
|
|
31
33
|
if px = opts[:prefix]
|
|
32
|
-
h[m.to_s[px.
|
|
34
|
+
h[m.to_s[px.length..-1]] = point.method(m) \
|
|
35
|
+
if m.to_s.start_with?(px)
|
|
33
36
|
else; sx = opts[:suffix]
|
|
34
|
-
h[m.to_s[0
|
|
37
|
+
h[m.to_s[0..-(sx.length + 1)]] = point.method(m) \
|
|
38
|
+
if m.to_s.end_with?(sx)
|
|
35
39
|
end
|
|
36
40
|
h }
|
|
37
41
|
).freeze
|