callable-mixin 0.2.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c4ab883eaeb5a2633c55642e2ad8aef2c97fc836d8eeb9a037e55d7e93bca84
4
- data.tar.gz: b5b8203b5653d12f6d40730a734dd29febf78fd8e6db065cc651dced0b6ec248
3
+ metadata.gz: 6d520e4dbd8dcb33dfd33e3422c464a2e29daa981c903f236813128cc975f03e
4
+ data.tar.gz: a2eac926cbcc9220682cf668ad4d747ceca36149b6ec4836019d24e030b0c2d8
5
5
  SHA512:
6
- metadata.gz: 2726c5f636c2ab6502db98a40afce7d237ae811d7a1b3c177c745b3926441ba2dd918b7a9dcb56800271e91b2ea624ade06de9e4da5233a07cdab20092eed547
7
- data.tar.gz: c46915a2fb9687b707aaea865bd4c002ae197a0ed2f84355a9a924bf380240d8b8a26170c5175d8a338337e25cee66db60f7a87c1fefe1da3c1c1c90546b1a50
6
+ metadata.gz: bec26a1c695e9f746ae883368e6f5977f4834eb069197bb381aa3477ac0123373afdf5f0bd7518a7b705ad9fdc4fd1c07bc52bfd4c6af90979ea5a99a7275a0b
7
+ data.tar.gz: 0c4244e4fe033ce6495327b7f31aa24e02aff56a64dd0f1165f324687a2e415b604e8cb83be21316e02c84363b5abe7d5abe8e3254c7e4436955799e3488c601
data/README.md CHANGED
@@ -123,7 +123,13 @@ After cloning the repo, install dependencies with `bundle install`, then run tes
123
123
 
124
124
  ## Contributing
125
125
 
126
- Bug reports and pull requests are welcome on GitHub at https://github.com/dbongo/callable-mixin.
126
+ Please follow these resources before submitting code or issues:
127
+
128
+ - [Code of Conduct](https://github.com/dbongo/callable-mixin/blob/main/.github/CODE_OF_CONDUCT.md)
129
+ - [Contributing Guide](https://github.com/dbongo/callable-mixin/blob/main/.github/CONTRIBUTING.md)
130
+ - [Pull Request Template](https://github.com/dbongo/callable-mixin/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
131
+
132
+ Bug reports and pull requests are welcome on GitHub: https://github.com/dbongo/callable-mixin
127
133
 
128
134
  ## License
129
135
 
@@ -33,15 +33,14 @@ module Callable
33
33
  ##
34
34
  # Instantiate the class and immediately invoke its instance `#call`.
35
35
  #
36
- # @param args [Array] positional arguments for `initialize`.
37
- # @param kwargs [Hash] keyword arguments for `initialize`.
36
+ # @param args [Array] positional and keyword arguments forwarded to `initialize`
37
+ # (keyword transparency provided by `ruby2_keywords`).
38
38
  # @yield [optional] block passed directly to the instance method `#call`; ignored if not yielded.
39
39
  # @return anything returned by the instance `#call`.
40
40
  # @raise [ConstructionError] if construction fails (plain `ArgumentError`).
41
41
  # @raise [NotImplementedError] if the instance does not implement `#call`.
42
- def call(*args, **kwargs, &block)
43
- # Ruby versions earlier than 2.7 can't reliably handle splatting empty kwargs, so branch for compatibility
44
- inst = kwargs.empty? ? new(*args) : new(*args, **kwargs)
42
+ def call(*args, &block)
43
+ inst = new(*args)
45
44
  rescue ArgumentError => e
46
45
  # Bubble up anything that isn't exactly ArgumentError (e.g., subclasses)
47
46
  raise unless e.instance_of?(ArgumentError)
@@ -53,6 +52,7 @@ module Callable
53
52
  end
54
53
  inst.call(&block)
55
54
  end
55
+ ruby2_keywords(:call) if respond_to?(:ruby2_keywords, true)
56
56
 
57
57
  # @return [Proc] a proc that delegates to `.call`, enabling `&MyService` shorthand.
58
58
  def to_proc
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Callable
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callable-mixin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Crowther