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 +4 -4
- data/README.md +7 -1
- data/lib/callable/mixin.rb +5 -5
- 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: 6d520e4dbd8dcb33dfd33e3422c464a2e29daa981c903f236813128cc975f03e
|
|
4
|
+
data.tar.gz: a2eac926cbcc9220682cf668ad4d747ceca36149b6ec4836019d24e030b0c2d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
|
data/lib/callable/mixin.rb
CHANGED
|
@@ -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
|
|
37
|
-
#
|
|
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,
|
|
43
|
-
|
|
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
|
data/lib/callable/version.rb
CHANGED