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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5a26558a5514a4af779fba9fbc1d015e88fa9c9f2c6a12d88aa274c3307e421
4
- data.tar.gz: 633c511d7f4f3509b275b3db38e246303ceed19db80c5dfbbb90df889c7d930f
3
+ metadata.gz: ff6115c057fbcfffd52d6037a190e9a36b23018f1c2b0745b2b9c7bb333cb86c
4
+ data.tar.gz: 4ebd7bdb25bdfbde7a762d333b9215f8e13909091fab11c1f048f52447e19b3c
5
5
  SHA512:
6
- metadata.gz: 51e7fdfc72e240d55189d69764f9fc8edb35e607eaa1374027d7c1a9478a6428f1bf28aee44971ba8929a75598a4a696a6f02f6370e73b98e0cc03f6cd34d64d
7
- data.tar.gz: b553bb218572e6f09af06680fb6c8d3774e3dac8e466f08400d9faf16c74e26cb23f1b00699901caf9db1bf60966d293a01255edfe6ebf9e31dac241c0e107d4
6
+ metadata.gz: 0d021ad9461294d8ee384d2302d25012b148e614c0deab1025d77da3a53355bbe62d326d9f29f15ed0685113523a577b13eef7a4d30ab81e323efaa59cecfb0a
7
+ data.tar.gz: 5469ed8b60c2d81cc89ad7f0a6debabf76b4f55e944f110365c2ed41db25379833f970acc288426ce61b123fffb6f3964cacc2d7ccc4689f9b7d3011b1654c02
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.2
4
+
5
+ Variable arity invoker methods are handled properly. Variable arity initializers will result in a more meaningful exception being raised.
6
+
3
7
  ## 0.7.1
4
8
 
5
9
  ### Invokable::call
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- invokable (0.7.1)
4
+ invokable (0.7.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- return new.call if arity == 0
65
- return new(*args).call if args.length == initializer_arity && invoker_arity == 0
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
@@ -1,3 +1,3 @@
1
1
  module Invokable
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
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.1
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-09-22 00:00:00.000000000 Z
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler