callable-mixin 0.1.0 → 0.1.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/lib/callable/mixin.rb +6 -10
- data/lib/callable/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: ce46528109d5c768c26cb19460e8f3a53870b466f0baa7f70bd5039daa44a9bf
|
|
4
|
+
data.tar.gz: ff3bdb350dd42f63a2b869f789dab3fdc706d4ac98379bb707f93cbcf3083036
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb8e1452063520635bfdde47bebfbe61af8c89fa56cce2ecda8123b87352e0af20bbf3ffbad4b019831edb4288f26539f81b8d4c04bcd9e1edd59316a5ab383d
|
|
7
|
+
data.tar.gz: 3de1d05026802704a791e15ee3b1f3ff33c5d219cfd94b61ecfc748e8c9d9fd1e44c4a0d102c8e40c3dd4bd8f16fd1f8c0238bcfa2979a688e0aad8fce40c62c
|
data/lib/callable/mixin.rb
CHANGED
|
@@ -18,12 +18,12 @@ module Callable
|
|
|
18
18
|
# @raise [ConstructionError] when instantiation fails
|
|
19
19
|
def call(*args, **kwargs, &block)
|
|
20
20
|
inst = begin
|
|
21
|
-
# avoids Ruby 2.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
# avoids Ruby 2.3–2.6 quirk
|
|
22
|
+
kwargs.empty? ? new(*args, &block) : new(*args, **kwargs, &block)
|
|
23
|
+
rescue ArgumentError => error
|
|
24
|
+
raise ConstructionError,
|
|
25
|
+
"Failed to construct #{name}.new with the supplied arguments: #{error.message}",
|
|
26
|
+
error.backtrace
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
if block_given? && inst.method(:call).arity.zero?
|
|
@@ -31,10 +31,6 @@ module Callable
|
|
|
31
31
|
else
|
|
32
32
|
inst.call
|
|
33
33
|
end
|
|
34
|
-
rescue ArgumentError => error
|
|
35
|
-
raise ConstructionError,
|
|
36
|
-
"Failed to construct #{name}.new with the supplied arguments: #{error.message}",
|
|
37
|
-
error.backtrace
|
|
38
34
|
end
|
|
39
35
|
end
|
|
40
36
|
end
|
data/lib/callable/version.rb
CHANGED