sorbet_operation 0.1.1 → 0.1.3

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: 512a04aba19ff48f6dd0a9dea9dd424f44afc008f1f3d2105a9777a1c4aac003
4
- data.tar.gz: 843ec9ec4160271da77074446fa4dd8addb40ae0cca39a49d26447e8612b03cb
3
+ metadata.gz: bd65b55fe7c00f797ad22f793cf45ad864660c7c6c2467ef04b718ed2996b20d
4
+ data.tar.gz: 8fd8de850c5bd11efbd30f18ec3d824ee49ec1e19ceb7423e9882996820a60cf
5
5
  SHA512:
6
- metadata.gz: a57964ba9985ed63f37ab45dbf82f79f633d36b98987b7f2c6efd584e92bbcb167b01e75869c92ab087d46b35d1cdeb487815a864a9591fbdc297d5baacbe542
7
- data.tar.gz: f1d3bec83764cc914f44b32f2495bcf9d3fa9637ce5e41357bab6f271a69d81aaf8b8ecf29cbdc92c6a5255d671cd2de73f1ff3d3e30106ae8f05a19291ff59e
6
+ metadata.gz: 03d97302dcbb44319b6f9041aa8483e8edf6d3ca90780c595deadddd71a75537827a681ef6b5c4cf5db777f1bcdcd7b2715495843c6743eeb140635f75662794
7
+ data.tar.gz: 67c86bfec1cb58446bc7c9609ecfd0ae39ed9b700b1b74e55d9c815b96e9958f47857294e0ecc4039b0848b3acc8da879f9554410c3abd4ef588c95a7e2c3319
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@
2
2
  inherit_gem:
3
3
  rubocop-shopify: rubocop.yml
4
4
 
5
- require:
5
+ plugins:
6
6
  - rubocop-minitest
7
7
  - rubocop-performance
8
8
  - rubocop-rake
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.6
1
+ 3.4.6
data/.yardopts CHANGED
@@ -1,3 +1,4 @@
1
1
  --markup markdown
2
2
  --protected
3
+ --private
3
4
  --plugin sorbet
data/Gemfile CHANGED
@@ -7,6 +7,10 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
+ gem "benchmark" # for Ruby >= 3.5
11
+ gem "bigdecimal" # for Ruby >= 3.4
12
+ gem "ostruct" # for Ruby >= 3.5
13
+
10
14
  group :development, :test do
11
15
  gem "irb"
12
16
  end
data/Gemfile.lock CHANGED
@@ -1,126 +1,154 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sorbet_operation (0.1.1)
4
+ sorbet_operation (0.1.3)
5
5
  sorbet-runtime (~> 0.5.10741)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ansi (1.5.0)
11
- ast (2.4.2)
12
- base64 (0.1.1)
13
- builder (3.2.4)
14
- bundler-audit (0.9.1)
11
+ ast (2.4.3)
12
+ benchmark (0.4.1)
13
+ bigdecimal (3.2.3)
14
+ builder (3.3.0)
15
+ bundler-audit (0.9.2)
15
16
  bundler (>= 1.2.0, < 3)
16
17
  thor (~> 1.0)
17
- diff-lcs (1.5.0)
18
- docile (1.4.0)
19
- erubi (1.12.0)
20
- io-console (0.6.0)
21
- irb (1.7.4)
22
- reline (>= 0.3.6)
23
- json (2.6.3)
24
- language_server-protocol (3.17.0.3)
25
- minitest (5.19.0)
26
- minitest-reporters (1.6.1)
18
+ date (3.4.1)
19
+ docile (1.4.1)
20
+ erb (5.0.2)
21
+ erubi (1.13.1)
22
+ io-console (0.8.1)
23
+ irb (1.15.2)
24
+ pp (>= 0.6.0)
25
+ rdoc (>= 4.0.0)
26
+ reline (>= 0.4.2)
27
+ json (2.15.0)
28
+ language_server-protocol (3.17.0.5)
29
+ lint_roller (1.1.0)
30
+ logger (1.7.0)
31
+ minitest (5.25.5)
32
+ minitest-reporters (1.7.1)
27
33
  ansi
28
34
  builder
29
35
  minitest (>= 5.0)
30
36
  ruby-progressbar
31
37
  netrc (0.11.0)
32
- parallel (1.23.0)
33
- parser (3.2.2.3)
38
+ ostruct (0.6.3)
39
+ parallel (1.27.0)
40
+ parser (3.3.9.0)
34
41
  ast (~> 2.4.1)
35
42
  racc
36
- prettier_print (1.2.1)
37
- racc (1.7.1)
43
+ pp (0.6.2)
44
+ prettyprint
45
+ prettyprint (0.2.0)
46
+ prism (1.5.1)
47
+ psych (5.2.6)
48
+ date
49
+ stringio
50
+ racc (1.8.1)
38
51
  rainbow (3.1.1)
39
- rake (13.0.6)
40
- rbi (0.0.17)
41
- ast
42
- parser (>= 3.0.0)
43
- sorbet-runtime (>= 0.5.9204)
44
- unparser (>= 0.5.6)
45
- regexp_parser (2.8.1)
46
- reline (0.3.8)
52
+ rake (13.3.0)
53
+ rbi (0.3.6)
54
+ prism (~> 1.0)
55
+ rbs (>= 3.4.4)
56
+ rbs (3.9.5)
57
+ logger
58
+ rdoc (6.14.2)
59
+ erb
60
+ psych (>= 4.0.0)
61
+ regexp_parser (2.11.3)
62
+ reline (0.6.2)
47
63
  io-console (~> 0.5)
48
- rexml (3.2.6)
49
- rubocop (1.56.1)
50
- base64 (~> 0.1.1)
64
+ rexml (3.4.4)
65
+ rubocop (1.80.2)
51
66
  json (~> 2.3)
52
- language_server-protocol (>= 3.17.0)
67
+ language_server-protocol (~> 3.17.0.2)
68
+ lint_roller (~> 1.1.0)
53
69
  parallel (~> 1.10)
54
- parser (>= 3.2.2.3)
70
+ parser (>= 3.3.0.2)
55
71
  rainbow (>= 2.2.2, < 4.0)
56
- regexp_parser (>= 1.8, < 3.0)
57
- rexml (>= 3.2.5, < 4.0)
58
- rubocop-ast (>= 1.28.1, < 2.0)
72
+ regexp_parser (>= 2.9.3, < 3.0)
73
+ rubocop-ast (>= 1.46.0, < 2.0)
59
74
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 2.4.0, < 3.0)
61
- rubocop-ast (1.29.0)
62
- parser (>= 3.2.1.0)
63
- rubocop-minitest (0.31.0)
64
- rubocop (>= 1.39, < 2.0)
65
- rubocop-performance (1.19.0)
66
- rubocop (>= 1.7.0, < 2.0)
67
- rubocop-ast (>= 0.4.0)
68
- rubocop-rake (0.6.0)
69
- rubocop (~> 1.0)
70
- rubocop-shopify (2.14.0)
71
- rubocop (~> 1.51)
72
- rubocop-sorbet (0.7.3)
73
- rubocop (>= 0.90.0)
75
+ unicode-display_width (>= 2.4.0, < 4.0)
76
+ rubocop-ast (1.47.1)
77
+ parser (>= 3.3.7.2)
78
+ prism (~> 1.4)
79
+ rubocop-minitest (0.38.2)
80
+ lint_roller (~> 1.1)
81
+ rubocop (>= 1.75.0, < 2.0)
82
+ rubocop-ast (>= 1.38.0, < 2.0)
83
+ rubocop-performance (1.26.0)
84
+ lint_roller (~> 1.1)
85
+ rubocop (>= 1.75.0, < 2.0)
86
+ rubocop-ast (>= 1.44.0, < 2.0)
87
+ rubocop-rake (0.7.1)
88
+ lint_roller (~> 1.1)
89
+ rubocop (>= 1.72.1)
90
+ rubocop-shopify (2.17.1)
91
+ rubocop (~> 1.62)
92
+ rubocop-sorbet (0.10.5)
93
+ lint_roller
94
+ rubocop (>= 1.75.2)
74
95
  ruby-progressbar (1.13.0)
75
96
  simplecov (0.22.0)
76
97
  docile (~> 1.1)
77
98
  simplecov-html (~> 0.11)
78
99
  simplecov_json_formatter (~> 0.1)
79
- simplecov-html (0.12.3)
100
+ simplecov-html (0.13.2)
80
101
  simplecov_json_formatter (0.1.4)
81
- sorbet (0.5.10983)
82
- sorbet-static (= 0.5.10983)
83
- sorbet-runtime (0.5.10983)
84
- sorbet-static (0.5.10983-universal-darwin-22)
85
- sorbet-static (0.5.10983-x86_64-linux)
86
- sorbet-static-and-runtime (0.5.10983)
87
- sorbet (= 0.5.10983)
88
- sorbet-runtime (= 0.5.10983)
89
- spoom (1.2.3)
102
+ sorbet (0.5.12443)
103
+ sorbet-static (= 0.5.12443)
104
+ sorbet-runtime (0.5.12443)
105
+ sorbet-static (0.5.12443-aarch64-linux)
106
+ sorbet-static (0.5.12443-universal-darwin)
107
+ sorbet-static (0.5.12443-x86_64-linux)
108
+ sorbet-static-and-runtime (0.5.12443)
109
+ sorbet (= 0.5.12443)
110
+ sorbet-runtime (= 0.5.12443)
111
+ spoom (1.6.3)
90
112
  erubi (>= 1.10.0)
113
+ prism (>= 0.28.0)
114
+ rbi (>= 0.3.3)
115
+ rexml (>= 3.2.6)
91
116
  sorbet-static-and-runtime (>= 0.5.10187)
92
- syntax_tree (>= 6.1.1)
93
117
  thor (>= 0.19.2)
94
- syntax_tree (6.1.1)
95
- prettier_print (>= 1.2.0)
96
- tapioca (0.11.8)
118
+ stringio (3.1.7)
119
+ tapioca (0.16.11)
120
+ benchmark
97
121
  bundler (>= 2.2.25)
98
122
  netrc (>= 0.11.0)
99
123
  parallel (>= 1.21.0)
100
- rbi (~> 0.0.0, >= 0.0.16)
101
- sorbet-static-and-runtime (>= 0.5.10187)
102
- spoom (~> 1.2.0, >= 1.2.0)
124
+ rbi (~> 0.2)
125
+ sorbet-static-and-runtime (>= 0.5.11087)
126
+ spoom (>= 1.2.0)
103
127
  thor (>= 1.2.0)
104
128
  yard-sorbet
105
- thor (1.2.2)
106
- unicode-display_width (2.4.2)
107
- unparser (0.6.8)
108
- diff-lcs (~> 1.3)
109
- parser (>= 3.2.0)
110
- yard (0.9.34)
111
- yard-sorbet (0.8.1)
112
- sorbet-runtime (>= 0.5)
113
- yard (>= 0.9)
129
+ thor (1.4.0)
130
+ unicode-display_width (3.2.0)
131
+ unicode-emoji (~> 4.1)
132
+ unicode-emoji (4.1.0)
133
+ yard (0.9.37)
134
+ yard-sorbet (0.9.0)
135
+ sorbet-runtime
136
+ yard
114
137
 
115
138
  PLATFORMS
116
- arm64-darwin-22
139
+ aarch64-linux
140
+ arm64-darwin
141
+ universal-darwin
117
142
  x86_64-linux
118
143
 
119
144
  DEPENDENCIES
145
+ benchmark
146
+ bigdecimal
120
147
  bundler-audit
121
148
  irb
122
149
  minitest (~> 5.0)
123
150
  minitest-reporters (~> 1.4)
151
+ ostruct
124
152
  rake (~> 13.0)
125
153
  rubocop
126
154
  rubocop-minitest
@@ -135,5 +163,68 @@ DEPENDENCIES
135
163
  yard
136
164
  yard-sorbet
137
165
 
166
+ CHECKSUMS
167
+ ansi (1.5.0) sha256=5408253274e33d9d27d4a98c46d2998266fd51cba58a7eb9d08f50e57ed23592
168
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
169
+ benchmark (0.4.1) sha256=d4ef40037bba27f03b28013e219b950b82bace296549ec15a78016552f8d2cce
170
+ bigdecimal (3.2.3) sha256=ffd11d1ac67a0d3b2f44aec0a6487210b3f813f363dd11f1fcccf5ba00da4e1b
171
+ builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
172
+ bundler-audit (0.9.2) sha256=73051daa09865c436450a35c4d87ceef15f3f9777f4aad4fd015cc6f1f2b1048
173
+ date (3.4.1) sha256=bf268e14ef7158009bfeaec40b5fa3c7271906e88b196d958a89d4b408abe64f
174
+ docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
175
+ erb (5.0.2) sha256=d30f258143d4300fb4ecf430042ac12970c9bb4b33c974a545b8f58c1ec26c0f
176
+ erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9
177
+ io-console (0.8.1) sha256=1e15440a6b2f67b6ea496df7c474ed62c860ad11237f29b3bd187f054b925fcb
178
+ irb (1.15.2) sha256=222f32952e278da34b58ffe45e8634bf4afc2dc7aa9da23fed67e581aa50fdba
179
+ json (2.15.0) sha256=bc24d490a1d81bcbf6b45ee5c02695545d4ed37f679cee879b789a2bbb53ad5c
180
+ language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
181
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
182
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
183
+ minitest (5.25.5) sha256=391b6c6cb43a4802bfb7c93af1ebe2ac66a210293f4a3fb7db36f2fc7dc2c756
184
+ minitest-reporters (1.7.1) sha256=5060413a0c95b8c32fe73e0606f3631c173a884d7900e50013e15094eb50562c
185
+ netrc (0.11.0) sha256=de1ce33da8c99ab1d97871726cba75151113f117146becbe45aa85cb3dabee3f
186
+ ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
187
+ parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
188
+ parser (3.3.9.0) sha256=94d6929354b1a6e3e1f89d79d4d302cc8f5aa814431a6c9c7e0623335d7687f2
189
+ pp (0.6.2) sha256=947ec3120c6f92195f8ee8aa25a7b2c5297bb106d83b41baa02983686577b6ff
190
+ prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
191
+ prism (1.5.1) sha256=b40c1b76ccb9fcccc3d1553967cda6e79fa7274d8bfea0d98b15d27a6d187134
192
+ psych (5.2.6) sha256=814328aa5dcb6d604d32126a20bc1cbcf05521a5b49dbb1a8b30a07e580f316e
193
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
194
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
195
+ rake (13.3.0) sha256=96f5092d786ff412c62fde76f793cc0541bd84d2eb579caa529aa8a059934493
196
+ rbi (0.3.6) sha256=577e94ddd123d7c83794dd62c06c5f9bf32a22e9a3a0d2f9baf32f7c81b2b5fa
197
+ rbs (3.9.5) sha256=eabaaf60aee84e38cbf94839c6e1b9cd145c7295fc3cc0e88c92e4069b1119b0
198
+ rdoc (6.14.2) sha256=9fdd44df130f856ae70cc9a264dfd659b9b40de369b16581f4ab746e42439226
199
+ regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
200
+ reline (0.6.2) sha256=1dad26a6008872d59c8e05244b119347c9f2ddaf4a53dce97856cd5f30a02846
201
+ rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
202
+ rubocop (1.80.2) sha256=6485f30fefcf5c199db3b91e5e253b1ef43f7e564784e2315255809a3dd9abf4
203
+ rubocop-ast (1.47.1) sha256=592682017855408b046a8190689490763aecea175238232b1b526826349d01ae
204
+ rubocop-minitest (0.38.2) sha256=5a9dfb5a538973d0601aa51e59637d3998bb8df81233edf1ff421504c6280068
205
+ rubocop-performance (1.26.0) sha256=7bb0d9d9fb2ea122bf6f9a596dd7cf9dc93ab4950923d26c4ae4f328cef71ca9
206
+ rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
207
+ rubocop-shopify (2.17.1) sha256=03850eb1a9c4d1f9f0ac1d8d5aa51bb47a149e532cfb5e8d02ac6a90c8800a5f
208
+ rubocop-sorbet (0.10.5) sha256=221672c096616d908a06aadd5111bfaab6d3c990d2a1caf2714cdec6514f4795
209
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
210
+ simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
211
+ simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
212
+ simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
213
+ sorbet (0.5.12443) sha256=9c52595b75f544284eee5e536f2ff86b7dfa370072227c56297e972bfdb28e6c
214
+ sorbet-runtime (0.5.12443) sha256=95a3667e2f2410857bca9952de98b88185b7e266c48e42ef4c6d2dc3fa73a6cc
215
+ sorbet-static (0.5.12443-aarch64-linux) sha256=418342d8925fa75285c73760e237dcb42994373d2d5f3b0bd7dcbdfb3f6dadbb
216
+ sorbet-static (0.5.12443-universal-darwin) sha256=99d0b9d5371ec9d449880154008d8b0aa1854c646ff83cdf1d7a29cda978d494
217
+ sorbet-static (0.5.12443-x86_64-linux) sha256=92915e823d312af2bd958f0700e529b5afd041492c6527198a2b60045f5a9e98
218
+ sorbet-static-and-runtime (0.5.12443) sha256=88ddf016cb6f238b14cc3c6d5324299e45f5957c9b1bae9c9509f864272ae2ea
219
+ sorbet_operation (0.1.3)
220
+ spoom (1.6.3) sha256=0d05a501a643a2e3cb75357583fcd0a400e92e05cd05a1bf1a08cda6d321d153
221
+ stringio (3.1.7) sha256=5b78b7cb242a315fb4fca61a8255d62ec438f58da2b90be66048546ade4507fa
222
+ tapioca (0.16.11) sha256=beeb388a5e2022ef8880cd24f57bc2acb59b65a4d5a6aa59bc1f10bc7b1eb1f7
223
+ thor (1.4.0) sha256=8763e822ccb0f1d7bee88cde131b19a65606657b847cc7b7b4b82e772bcd8a3d
224
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
225
+ unicode-emoji (4.1.0) sha256=4997d2d5df1ed4252f4830a9b6e86f932e2013fbff2182a9ce9ccabda4f325a5
226
+ yard (0.9.37) sha256=a6e910399e78e613f80ba9add9ba7c394b1a935f083cccbef82903a3d2a26992
227
+ yard-sorbet (0.9.0) sha256=03d1aa461b9e9c82b886919a13aa3e09fcf4d1852239d2967ed97e92723ffe21
228
+
138
229
  BUNDLED WITH
139
- 2.4.3
230
+ 2.7.2
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # sorbet_operation
2
2
 
3
3
  [![Build Status](https://github.com/thatch-health/sorbet_operation/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/thatch-health/sorbet_operation/actions?query=branch%3Amain)
4
+ [![Gem Version ](https://img.shields.io/gem/v/sorbet_operation.svg?style=flat)](https://rubygems.org/gems/sorbet_operation)
5
+ [![YARD Docs](https://img.shields.io/badge/yard-docs-blue?logo=readthedocs)](https://thatch-health.github.io/sorbet_operation/)
4
6
 
5
7
  sorbet_operation is a minimal operation framework that leverages Sorbet's type system to ensure that operations are well-typed and that their inputs and outputs are well-defined.
6
8
 
@@ -16,7 +18,7 @@ class CreateUser < SorbetOperation::Base
16
18
  @user_params = user_params
17
19
  end
18
20
 
19
- protected
21
+ private
20
22
 
21
23
  sig { returns(ValueType) }
22
24
  def execute
@@ -32,13 +34,13 @@ In a Rails controller, this operation could be used as follows:
32
34
  class UsersController < ApplicationController
33
35
  def create
34
36
  result = CreateUser.new(user_params).perform
35
- if operation.success?
37
+ if result.success?
36
38
  user = result.unwrap!
37
39
  T.reveal_type(user) # `User`
38
40
  redirect_to user
39
41
  else
40
42
  error = result.unwrap_error!
41
- T.reveal_type(error) # `SorbetOperation::Error`
43
+ T.reveal_type(error) # `SorbetOperation::Failure`
42
44
  render :new, alert: error.message
43
45
  end
44
46
  end
@@ -51,24 +53,17 @@ class UsersController < ApplicationController
51
53
  end
52
54
  ```
53
55
 
54
- Operations return a result object which indicates whether the operation was successful or not. The result object wraps the return value of the operation if it was successful, or an instance of `SorbetOperation::Error` if it failed.
56
+ Operations return a result object which indicates whether the operation was successful or not. The result object wraps the return value of the operation if it was successful, or an instance of `SorbetOperation::Failure` if it failed.
55
57
 
56
58
  ## Installation
57
59
 
58
- This gem is not yet published to RubyGems.org. For now, you can install it by adding the following to your `Gemfile`:
59
- ```ruby
60
- gem "sorbet_operation", github: "thatch-health/sorbet_operation", branch: "main"
61
- ```
62
-
63
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
64
-
65
60
  Install the gem and add to the application's Gemfile by executing:
66
61
 
67
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
62
+ $ bundle add sorbet_operation
68
63
 
69
64
  If bundler is not being used to manage dependencies, install the gem by executing:
70
65
 
71
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
66
+ $ gem install sorbet_operation
72
67
 
73
68
  ## Usage
74
69
 
@@ -76,15 +71,15 @@ An operation is a Ruby class that derives from `SorbetOperation::Base`. `SorbetO
76
71
  1. define the return type using the `ValueType` generic type member
77
72
  2. define an `#execute` method that returns a `ValueType`
78
73
 
79
- The `#execute` method should be `protected` or `private`, since it is not meant to be invoked directly; rather, operation callers should use the `#perform` public method to actually perform the operation. (Unfortunately, at this time there is no mechanism to enforce that `#execute` is not a public method on child classes, so it's up to the programmer to be vigilant.)
74
+ The `#execute` method should be `private`, since it is not meant to be invoked directly; rather, operation callers should use the `#perform` public method to actually perform the operation. (Unfortunately, at this time there is no mechanism to enforce that `#execute` is not a public method on child classes, so it's up to the programmer to be vigilant.)
80
75
 
81
76
  The `#execute` method does not take any arguments. Most operations require one or more input values. Input values should be passed to the `#initialize` constructor method and stored as instance variables, which can then be accessed from the `#execute` body.
82
77
 
83
78
  There are two possible outcomes for an operation:
84
79
  1. if `#execute` returns an instance of `ValueType`, then the operation result is a success
85
- 2. if `#execute` raises a `SorbetOperation::Error`, then the operation result is a failure
80
+ 2. if `#execute` raises a `SorbetOperation::Failure`, then the operation result is a failure
86
81
 
87
- Exceptions that are not an instance of `SorbetOperation::Error` will not be caught by the framework and will be propagated to the operation callsite.
82
+ Exceptions that are not an instance of `SorbetOperation::Failure` will not be caught by the framework and will be propagated to the operation callsite.
88
83
 
89
84
  ### Using results
90
85
 
@@ -38,16 +38,16 @@ module SorbetOperation
38
38
  # Performs the operation and returns the result.
39
39
  sig { returns(Result[ValueType]) }
40
40
  def perform
41
- logger.debug("Performing operation #{self.class.name}")
41
+ logger.debug { "Performing operation #{self.class.name}" }
42
42
 
43
43
  begin
44
44
  value = execute
45
45
  rescue Failure => e
46
- logger.debug("Operation #{self.class.name} failed, failure = #{e.inspect}")
46
+ logger.debug { "Operation #{self.class.name} failed, failure = #{e.inspect}" }
47
47
 
48
48
  Result.new(false, nil, e)
49
49
  else
50
- logger.debug("Operation #{self.class.name} succeeded, return value = #{value.inspect}")
50
+ logger.debug { "Operation #{self.class.name} succeeded, return value = #{value.inspect}" }
51
51
 
52
52
  Result.new(true, value, nil)
53
53
  end
@@ -57,7 +57,7 @@ module SorbetOperation
57
57
  sig { params(logger: ::Logger).void }
58
58
  attr_writer :logger
59
59
 
60
- protected
60
+ private
61
61
 
62
62
  # Implement this method in subclasses to perform the operation.
63
63
  #
@@ -70,7 +70,7 @@ module SorbetOperation
70
70
  # exception. The exception will not be caught and will be propagated to
71
71
  # the caller.
72
72
  #
73
- # This method should be declared as `protected` in subclasses to prevent
73
+ # This method should be declared as `private` in subclasses to prevent
74
74
  # callers from calling it directly. Callers should instead call {#perform}
75
75
  # to perform the operation and get the result.
76
76
  sig { abstract.returns(ValueType) }
@@ -7,7 +7,7 @@ module SorbetOperation
7
7
  # Exception class used to indicate that an operation failed.
8
8
  #
9
9
  # Raise this exception (or a subclass of it) from an operation's
10
- # {SorbetOperation::Operation#execute} method to indicate that the operation
10
+ # {SorbetOperation::Base#execute} method to indicate that the operation
11
11
  # failed.
12
12
  #
13
13
  # If you need to pass additional information about the failure, you can
@@ -192,6 +192,8 @@ module SorbetOperation
192
192
  # runtime error if `ValueType` is nilable and `@value` is `nil`.
193
193
  #
194
194
  # There's probably a better way to handle this.
195
+ #
196
+ # @private
195
197
  sig { returns(ValueType) }
196
198
  def casted_value
197
199
  T.cast(@value, ValueType)
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module SorbetOperation
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.3"
6
6
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["sorbet-operation@thatch.ai"]
10
10
 
11
11
  spec.summary = "Sorbet-powered operation framework."
12
- spec.description = "sorbet_operation is a minimal operation framework that leverages Sorbet's type system to "\
12
+ spec.description = "sorbet_operation is a minimal operation framework that leverages Sorbet's type system to " \
13
13
  "ensure that operations are well-typed and that their inputs and outputs are well-defined."
14
14
  spec.homepage = "https://github.com/thatch-health/sorbet_operation"
15
15
  spec.license = "MIT"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thatch Health, Inc.
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-08-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: sorbet-runtime
@@ -55,7 +54,6 @@ metadata:
55
54
  homepage_uri: https://github.com/thatch-health/sorbet_operation
56
55
  source_code_uri: https://github.com/thatch-health/sorbet_operation
57
56
  changelog_uri: https://github.com/thatch-health/sorbet_operation/blob/main/CHANGELOG.md
58
- post_install_message:
59
57
  rdoc_options: []
60
58
  require_paths:
61
59
  - lib
@@ -70,8 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
68
  - !ruby/object:Gem::Version
71
69
  version: '0'
72
70
  requirements: []
73
- rubygems_version: 3.4.10
74
- signing_key:
71
+ rubygems_version: 3.6.9
75
72
  specification_version: 4
76
73
  summary: Sorbet-powered operation framework.
77
74
  test_files: []