constructor_shortcut 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 21d79b4c674c5667c3eb6bfdd4af31722ede45f0
4
- data.tar.gz: 9a42f2c76c08fb9054a72648100ca69f98e443f6
3
+ metadata.gz: 6642a099c707719c7c07500fbf1d45bcbfa26142
4
+ data.tar.gz: 8bef539818e06c0e7ed7e45589cb908ff34e04c1
5
5
  SHA512:
6
- metadata.gz: 445ae2bfb722fcc9146c5928190acfd36e2f8acf58aa1fd78c431c5791a88decb295430826fb124d832c48a4759674ee4149d2eebeb32f474940bcb3ec1223ef
7
- data.tar.gz: 45703c3c8036be719459f4e954da4fd180c128d47803b4245d277eae52b54d0f74ce417cb72ee3b658aa28088070d1dff14aa0479dfae2c9f2fc87a6473c78cb
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
@@ -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 name do |*args, &block|
22
+ define_method class_name do |*args, &block|
23
23
  new(*args, &block).public_send(name)
24
24
  end
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module ConstructorShortcut
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  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.3.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: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2019-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler