invokable 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/invokable.rb +8 -6
- data/lib/invokable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff6115c057fbcfffd52d6037a190e9a36b23018f1c2b0745b2b9c7bb333cb86c
|
4
|
+
data.tar.gz: 4ebd7bdb25bdfbde7a762d333b9215f8e13909091fab11c1f048f52447e19b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d021ad9461294d8ee384d2302d25012b148e614c0deab1025d77da3a53355bbe62d326d9f29f15ed0685113523a577b13eef7a4d30ab81e323efaa59cecfb0a
|
7
|
+
data.tar.gz: 5469ed8b60c2d81cc89ad7f0a6debabf76b4f55e944f110365c2ed41db25379833f970acc288426ce61b123fffb6f3964cacc2d7ccc4689f9b7d3011b1654c02
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/invokable.rb
CHANGED
@@ -50,7 +50,9 @@ module Invokable
|
|
50
50
|
#
|
51
51
|
# @return [Integer]
|
52
52
|
def arity
|
53
|
-
initializer_arity + invoker_arity
|
53
|
+
return initializer_arity + invoker_arity if invoker_arity >= 0
|
54
|
+
|
55
|
+
(initializer_arity + invoker_arity.abs) * -1
|
54
56
|
end
|
55
57
|
|
56
58
|
# Handle automatic currying--will accept either the initializer arity or the total arity of the class. If
|
@@ -61,11 +63,13 @@ module Invokable
|
|
61
63
|
#
|
62
64
|
# @see arity
|
63
65
|
def call(*args)
|
64
|
-
|
65
|
-
|
66
|
+
raise ArgumentError, "variable length initializer methods are not supported by Invokable" if initializer_arity < 0
|
67
|
+
|
68
|
+
return new.call if arity.zero?
|
69
|
+
return new(*args).call if args.length == initializer_arity && (invoker_arity.zero? || invoker_arity == -1)
|
66
70
|
return new(*args) if args.length == initializer_arity
|
67
71
|
|
68
|
-
if args.length == arity
|
72
|
+
if args.length == arity || invoker_arity < 0 && (args.length - initializer_arity) >= (invoker_arity.abs - 1)
|
69
73
|
init_args = args.slice(0, initializer_arity)
|
70
74
|
call_args = args.slice(initializer_arity, args.length)
|
71
75
|
new(*init_args).call(*call_args)
|
@@ -74,8 +78,6 @@ module Invokable
|
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
77
|
-
private
|
78
|
-
|
79
81
|
def initializer_arity
|
80
82
|
instance_method(:initialize).arity
|
81
83
|
end
|
data/lib/invokable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invokable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delon Newman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|