constructor_shortcut 0.3.0 → 0.4.0
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 +21 -0
- data/lib/constructor_shortcut.rb +2 -2
- data/lib/constructor_shortcut/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6642a099c707719c7c07500fbf1d45bcbfa26142
|
4
|
+
data.tar.gz: 8bef539818e06c0e7ed7e45589cb908ff34e04c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a163f39bd64e9294f6a47a06a39fe7800a1fd40f55c7e11577691e3d38e77a3585bc919a39d2604db882b184c596fd5d1ac7676c06e7a8c3abd30a203c12706
|
7
|
+
data.tar.gz: 44f3c682398779f61dd8d7d78bdd20650249565603232af34900cfbc4b910c7c240f5a02abd4b53a9833d41ea6a2f736a28867e6998e65647b778e723f07d269
|
data/README.md
CHANGED
@@ -24,6 +24,8 @@ class CallableServiceObject
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
CallableServiceObject.new(1).call
|
27
29
|
```
|
28
30
|
|
29
31
|
After:
|
@@ -39,6 +41,25 @@ class CallableServiceObject
|
|
39
41
|
foo * 2
|
40
42
|
end
|
41
43
|
end
|
44
|
+
|
45
|
+
CallableServiceObject.call(1)
|
46
|
+
```
|
47
|
+
|
48
|
+
Additionally:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
class CallableServiceObject
|
52
|
+
extend Dry::Initializer
|
53
|
+
extend ConstructorShortcut[:call, :[]]
|
54
|
+
|
55
|
+
param :foo
|
56
|
+
|
57
|
+
def call
|
58
|
+
foo * 2
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
CallableServiceObject[1]
|
42
63
|
```
|
43
64
|
|
44
65
|
## Installation
|
data/lib/constructor_shortcut.rb
CHANGED
@@ -4,7 +4,7 @@ require "constructor_shortcut/version"
|
|
4
4
|
module ConstructorShortcut
|
5
5
|
# Used to set method name
|
6
6
|
# rubocop:disable Metrics/MethodLength
|
7
|
-
def self.[](name = :call)
|
7
|
+
def self.[](name = :call, class_name = :call)
|
8
8
|
@cache ||= {}
|
9
9
|
@cache[name] ||=
|
10
10
|
Module.new do
|
@@ -19,7 +19,7 @@ module ConstructorShortcut
|
|
19
19
|
alias_method :inspect, :name
|
20
20
|
end
|
21
21
|
|
22
|
-
define_method
|
22
|
+
define_method class_name do |*args, &block|
|
23
23
|
new(*args, &block).public_send(name)
|
24
24
|
end
|
25
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructor_shortcut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|