u-case 3.0.0.rc7 → 3.0.0.rc8

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
  SHA256:
3
- metadata.gz: 0102a68d35e94a3fec4c86a68289412a97d8aa5b9bf960b3dc08cc122b990f80
4
- data.tar.gz: 7183f0447bb6b79315bf9425d3ec77037bc1b7a99384cdf8b3aa3e061cb9ea8b
3
+ metadata.gz: c2265a60386ce542b8ee6006a58d4fb801dcfb396d7dfcf84d342910095fcbf8
4
+ data.tar.gz: 1502d1a284c616860ae99e0c03fe02a81be3e9d0adc0cc75a414825b4132f792
5
5
  SHA512:
6
- metadata.gz: 1c9403cbe651b87a63ac73e65c7dc72158a095f1edfd5789ed84e4024418f7b2ca34d99f3319f098459ec22c9211b0d372694fddb9242e53fbdae5cf3f59edd7
7
- data.tar.gz: 65194dbc56bf9f6ae785c6980643b625a8d8c96be63700ea1b10343e5cac3fa317eb4aee4a0d787116a64738dcc26c6b5ed7beeda67de09a006c48868d194b1d
6
+ metadata.gz: ab5c45e1e1e12f157a4e5f5fa596fdb778e6bd6267d5111e438094ff37e017a0452e4a1d85a39df0e63ec28876260bad8f7c4a56ca18796a95805187efe2d002
7
+ data.tar.gz: 6cefcdbbb39a4400bbd4c52b7ccf77f2c142958680049a3e53f4af37d1ef696fdc3a9019cde0f8f18463dd814e79e9753ef5a270eb446dbb2bee81e7c734ffab
data/.travis.sh CHANGED
@@ -3,17 +3,21 @@
3
3
  ruby_v=$(ruby -v)
4
4
 
5
5
  ACTIVEMODEL_VERSION='3.2' bundle update
6
- ACTIVEMODEL_VERSION='3.2' bundle exec rake test
6
+ ACTIVEMODEL_VERSION='3.2' ENABLE_TRANSITIONS='true' bundle exec rake test
7
+ ACTIVEMODEL_VERSION='3.2' ENABLE_TRANSITIONS='false' bundle exec rake test
7
8
 
8
9
  if [[ ! $ruby_v =~ '2.2.0' ]]; then
9
10
  ACTIVEMODEL_VERSION='5.2' bundle update
10
- ACTIVEMODEL_VERSION='5.2' bundle exec rake test
11
+ ACTIVEMODEL_VERSION='5.2' ENABLE_TRANSITIONS='true' bundle exec rake test
12
+ ACTIVEMODEL_VERSION='5.2' ENABLE_TRANSITIONS='false' bundle exec rake test
11
13
  fi
12
14
 
13
15
  if [[ $ruby_v =~ '2.5.' ]] || [[ $ruby_v =~ '2.6.' ]] || [[ $ruby_v =~ '2.7.' ]]; then
14
16
  ACTIVEMODEL_VERSION='6.0' bundle update
15
- ACTIVEMODEL_VERSION='6.0' bundle exec rake test
17
+ ACTIVEMODEL_VERSION='6.0' ENABLE_TRANSITIONS='true' bundle exec rake test
18
+ ACTIVEMODEL_VERSION='6.0' ENABLE_TRANSITIONS='false' bundle exec rake test
16
19
  fi
17
20
 
18
21
  bundle update
19
- bundle exec rake test
22
+ ENABLE_TRANSITIONS='true' bundle exec rake test
23
+ ENABLE_TRANSITIONS='false' bundle exec rake test
data/README.md CHANGED
@@ -21,7 +21,7 @@ The main project goals are:
21
21
 
22
22
  Version | Documentation
23
23
  --------- | -------------
24
- 3.0.0.rc7 | https://github.com/serradura/u-case/blob/main/README.md
24
+ 3.0.0.rc8 | https://github.com/serradura/u-case/blob/main/README.md
25
25
  2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
26
26
  1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
27
27
 
@@ -66,9 +66,9 @@ Version | Documentation
66
66
  - [`Micro::Cases::Flow` (v3.0.0)](#microcasesflow-v300)
67
67
  - [Comparisons](#comparisons)
68
68
  - [Examples](#examples)
69
- - [1️⃣ Rails App (API)](#1️⃣-rails-app-api)
70
- - [2️⃣ CLI calculator](#2️⃣-cli-calculator)
71
- - [3️⃣ Users creation](#3️⃣-users-creation)
69
+ - [1️⃣ Users creation](#1️⃣-users-creation)
70
+ - [2️⃣ Rails App (API)](#2️⃣-rails-app-api)
71
+ - [3️⃣ CLI calculator](#3️⃣-cli-calculator)
72
72
  - [4️⃣ Rescuing exceptions inside of the use cases](#4️⃣-rescuing-exceptions-inside-of-the-use-cases)
73
73
  - [Development](#development)
74
74
  - [Contributing](#contributing)
@@ -79,7 +79,7 @@ Version | Documentation
79
79
 
80
80
  | u-case | branch | ruby | activemodel |
81
81
  | -------------- | ------- | -------- | ------------- |
82
- | 3.0.0.rc7 | main | >= 2.2.0 | >= 3.2, < 6.1 |
82
+ | 3.0.0.rc8 | main | >= 2.2.0 | >= 3.2, < 6.1 |
83
83
  | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 |
84
84
  | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 |
85
85
 
@@ -102,7 +102,7 @@ Version | Documentation
102
102
  Add this line to your application's Gemfile:
103
103
 
104
104
  ```ruby
105
- gem 'u-case', '~> 3.0.0.rc7'
105
+ gem 'u-case', '~> 3.0.0.rc8'
106
106
  ```
107
107
 
108
108
  And then execute:
@@ -1176,42 +1176,42 @@ end
1176
1176
 
1177
1177
  | Gem / Abstraction | Iterations per second | Comparison |
1178
1178
  | ----------------- | --------------------: | ----------------: |
1179
- | Dry::Monads | 139037.7 | _**The Fastest**_ |
1180
- | **Micro::Case** | 101497.3 | 1.37x slower |
1181
- | Interactor | 30694.2 | 4.53x slower |
1182
- | Trailblazer::Operation | 14580.8 | 9.54x slower |
1183
- | Dry::Transaction | 5728.0 | 24.27x slower |
1179
+ | Dry::Monads | 141730.1 | _**The Fastest**_ |
1180
+ | **Micro::Case** | 103541.3 | 1.37x slower |
1181
+ | Interactor | 29100.8 | 4.87x slower |
1182
+ | Trailblazer::Operation | 15031.4 | 9.43x slower |
1183
+ | Dry::Transaction | 5674.0 | 24.98x slower |
1184
1184
 
1185
1185
  <details>
1186
1186
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1187
1187
 
1188
1188
  ```ruby
1189
1189
  # Warming up --------------------------------------
1190
- # Interactor 3.056k i/100ms
1191
- # Trailblazer::Operation 1.480k i/100ms
1192
- # Dry::Monads 14.316k i/100ms
1193
- # Dry::Transaction 576.000 i/100ms
1194
- # Micro::Case 10.388k i/100ms
1195
- # Micro::Case::Strict 8.223k i/100ms
1196
- # Micro::Case::Safe 10.057k i/100ms
1190
+ # Interactor 2.915k i/100ms
1191
+ # Trailblazer::Operation 1.543k i/100ms
1192
+ # Dry::Monads 14.288k i/100ms
1193
+ # Dry::Transaction 571.000 i/100ms
1194
+ # Micro::Case 10.418k i/100ms
1195
+ # Micro::Case::Strict 8.296k i/100ms
1196
+ # Micro::Case::Safe 10.254k i/100ms
1197
1197
 
1198
1198
  # Calculating -------------------------------------
1199
- # Interactor 30.694k (± 2.3%) i/s - 155.856k in 5.080475s
1200
- # Trailblazer::Operation 14.581k3.9%) i/s - 74.000k in 5.083091s
1201
- # Dry::Monads 139.038k (± 3.0%) i/s - 701.484k in 5.049921s
1202
- # Dry::Transaction 5.728k3.6%) i/s - 28.800k in 5.034599s
1203
- # Micro::Case 100.712k3.4%) i/s - 509.012k in 5.060139s
1204
- # Micro::Case::Strict 81.513k3.4%) i/s - 411.150k in 5.049962s
1205
- # Micro::Case::Safe 101.497k3.1%) i/s - 512.907k in 5.058463s
1199
+ # Interactor 29.101k (± 2.1%) i/s - 145.750k in 5.010660s
1200
+ # Trailblazer::Operation 15.031k2.0%) i/s - 75.607k in 5.032071s
1201
+ # Dry::Monads 141.730k (± 3.1%) i/s - 714.400k in 5.045546s
1202
+ # Dry::Transaction 5.674k1.9%) i/s - 28.550k in 5.033564s
1203
+ # Micro::Case 103.541k1.6%) i/s - 520.900k in 5.032077s
1204
+ # Micro::Case::Strict 83.045k2.4%) i/s - 423.096k in 5.098031s
1205
+ # Micro::Case::Safe 101.662k1.5%) i/s - 512.700k in 5.044386s
1206
1206
 
1207
1207
  # Comparison:
1208
- # Dry::Monads: 139037.7 i/s
1209
- # Micro::Case::Safe: 101497.3 i/s - 1.37x (± 0.00) slower
1210
- # Micro::Case: 100711.6 i/s - 1.38x (± 0.00) slower
1211
- # Micro::Case::Strict: 81512.9 i/s - 1.71x (± 0.00) slower
1212
- # Interactor: 30694.2 i/s - 4.53x (± 0.00) slower
1213
- # Trailblazer::Operation: 14580.8 i/s - 9.54x (± 0.00) slower
1214
- # Dry::Transaction: 5728.0 i/s - 24.27x (± 0.00) slower
1208
+ # Dry::Monads: 141730.1 i/s
1209
+ # Micro::Case: 103541.3 i/s - 1.37x (± 0.00) slower
1210
+ # Micro::Case::Safe: 101662.2 i/s - 1.39x (± 0.00) slower
1211
+ # Micro::Case::Strict: 83044.6 i/s - 1.71x (± 0.00) slower
1212
+ # Interactor: 29100.8 i/s - 4.87x (± 0.00) slower
1213
+ # Trailblazer::Operation: 15031.4 i/s - 9.43x (± 0.00) slower
1214
+ # Dry::Transaction: 5674.0 i/s - 24.98x (± 0.00) slower
1215
1215
  ```
1216
1216
  </details>
1217
1217
 
@@ -1221,42 +1221,42 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_success_r
1221
1221
 
1222
1222
  | Gem / Abstraction | Iterations per second | Comparison |
1223
1223
  | ----------------- | --------------------: | ----------------: |
1224
- | **Micro::Case** | 94619.6 | _**The Fastest**_ |
1225
- | Dry::Monads | 70250.6 | 1.35x slower |
1226
- | Trailblazer::Operation | 14786.1 | 6.40x slower |
1227
- | Interactor | 13770.0 | 6.87x slower |
1228
- | Dry::Transaction | 4994.4 | 18.95x slower |
1224
+ | **Micro::Case** | 98820.8 | _**The Fastest**_ |
1225
+ | Dry::Monads | 71329.7 | 1.39x slower |
1226
+ | Trailblazer::Operation | 15034.9 | 6.57x slower |
1227
+ | Interactor | 13958.7 | 7.08x slower |
1228
+ | Dry::Transaction | 5067.5 | 19.50x slower |
1229
1229
 
1230
1230
  <details>
1231
1231
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1232
1232
 
1233
1233
  ```ruby
1234
1234
  # Warming up --------------------------------------
1235
- # Interactor 1.408k i/100ms
1236
- # Trailblazer::Operation 1.492k i/100ms
1237
- # Dry::Monads 7.224k i/100ms
1238
- # Dry::Transaction 501.000 i/100ms
1239
- # Micro::Case 9.664k i/100ms
1240
- # Micro::Case::Strict 7.823k i/100ms
1241
- # Micro::Case::Safe 9.464k i/100ms
1235
+ # Interactor 1.324k i/100ms
1236
+ # Trailblazer::Operation 1.525k i/100ms
1237
+ # Dry::Monads 7.126k i/100ms
1238
+ # Dry::Transaction 499.000 i/100ms
1239
+ # Micro::Case 9.919k i/100ms
1240
+ # Micro::Case::Strict 7.837k i/100ms
1241
+ # Micro::Case::Safe 9.762k i/100ms
1242
1242
 
1243
1243
  # Calculating -------------------------------------
1244
- # Interactor 13.770k4.3%) i/s - 68.992k in 5.020330s
1245
- # Trailblazer::Operation 14.786k5.3%) i/s - 74.600k in 5.064700s
1246
- # Dry::Monads 70.251k6.7%) i/s - 353.976k in 5.063010s
1247
- # Dry::Transaction 4.994k4.0%) i/s - 25.050k in 5.023997s
1248
- # Micro::Case 94.620k3.8%) i/s - 473.536k in 5.012483s
1249
- # Micro::Case::Strict 76.059k (± 3.0%) i/s - 383.327k in 5.044482s
1250
- # Micro::Case::Safe 91.719k5.6%) i/s - 463.736k in 5.072552s
1244
+ # Interactor 13.959k2.5%) i/s - 70.172k in 5.030240s
1245
+ # Trailblazer::Operation 15.035k2.2%) i/s - 76.250k in 5.074108s
1246
+ # Dry::Monads 71.330k2.4%) i/s - 363.426k in 5.097993s
1247
+ # Dry::Transaction 5.068k1.9%) i/s - 25.449k in 5.023922s
1248
+ # Micro::Case 98.821k2.9%) i/s - 495.950k in 5.023421s
1249
+ # Micro::Case::Strict 79.936k (± 3.1%) i/s - 399.687k in 5.005435s
1250
+ # Micro::Case::Safe 98.695k1.9%) i/s - 497.862k in 5.046246s
1251
1251
 
1252
1252
  # Comparison:
1253
- # Micro::Case: 94619.6 i/s
1254
- # Micro::Case::Safe: 91719.4 i/s - same-ish: difference falls within error
1255
- # Micro::Case::Strict: 76058.7 i/s - 1.24x (± 0.00) slower
1256
- # Dry::Monads: 70250.6 i/s - 1.35x (± 0.00) slower
1257
- # Trailblazer::Operation: 14786.1 i/s - 6.40x (± 0.00) slower
1258
- # Interactor: 13770.0 i/s - 6.87x (± 0.00) slower
1259
- # Dry::Transaction: 4994.4 i/s - 18.95x (± 0.00) slower
1253
+ # Micro::Case: 98820.8 i/s
1254
+ # Micro::Case::Safe: 98695.0 i/s - same-ish: difference falls within error
1255
+ # Micro::Case::Strict: 79935.9 i/s - 1.24x (± 0.00) slower
1256
+ # Dry::Monads: 71329.7 i/s - 1.39x (± 0.00) slower
1257
+ # Trailblazer::Operation: 15034.9 i/s - 6.57x (± 0.00) slower
1258
+ # Interactor: 13958.7 i/s - 7.08x (± 0.00) slower
1259
+ # Dry::Transaction: 5067.5 i/s - 19.50x (± 0.00) slower
1260
1260
  ```
1261
1261
  </details>
1262
1262
 
@@ -1269,10 +1269,11 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1269
1269
  | Gems / Abstraction | [Success results](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_success_result.rb#L40) | [Failure results](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_failure_result.rb#L40) |
1270
1270
  | ------------------------------------------- | ----------------: | ----------------: |
1271
1271
  | Micro::Case internal flow (private methods) | _**The Fastest**_ | _**The Fastest**_ |
1272
- | Micro::Case `then` method | 1.48x slower | 0x slower |
1273
- | Micro::Cases.flow | 1.62x slower | 1.16x slower |
1274
- | Micro::Cases.safe_flow | 1.64x slower | 1.16x slower |
1275
- | Interactor::Organizer | 1.95x slower | 6.17x slower |
1272
+ | Micro::Case internal flow (through lambdas) | 1.03x slower | 1.04x slower |
1273
+ | Micro::Case `then` method | 1.49x slower | 0x slower |
1274
+ | Micro::Cases.flow | 1.53x slower | 1.04x slower |
1275
+ | Micro::Cases.safe_flow | 1.54x slower | 1.04x slower |
1276
+ | Interactor::Organizer | 2.05x slower | 6.27x slower |
1276
1277
 
1277
1278
  \* The `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` gems are out of this analysis because all of them doesn't have this kind of feature.
1278
1279
 
@@ -1281,25 +1282,40 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1281
1282
 
1282
1283
  ```ruby
1283
1284
  # Warming up --------------------------------------
1284
- # Interactor::Organizer 5.219k i/100ms
1285
- # Micro::Cases.flow([]) 6.451k i/100ms
1286
- # Micro::Cases::safe_flow([]) 6.421k i/100ms
1287
- # Micro::Case flow using `then` method 7.139k i/100ms
1288
- # Micro::Case flow using private methods 10.355k i/100ms
1285
+ # Interactor::Organizer
1286
+ # 4.837k i/100ms
1287
+ # Micro::Cases.flow([])
1288
+ # 6.755k i/100ms
1289
+ # Micro::Cases::safe_flow([])
1290
+ # 6.809k i/100ms
1291
+ # Micro::Case flow using `then` method
1292
+ # 6.968k i/100ms
1293
+ # Micro::Case flow using private methods
1294
+ # 10.362k i/100ms
1295
+ # Micro::Case flow using private methods through lambdas
1296
+ # 10.258k i/100ms
1289
1297
 
1290
1298
  # Calculating -------------------------------------
1291
- # Interactor::Organizer 52.959k (± 1.7%) i/s - 266.169k in 5.027332s
1292
- # Micro::Cases.flow([]) 63.947k (± 1.7%) i/s - 322.550k in 5.045597s
1293
- # Micro::Cases::safe_flow([]) 63.047k (± 3.1%) i/s - 321.050k in 5.097228s
1294
- # Micro::Case flow using `then` method 69.644k4.0%) i/s - 349.811k in 5.031120s
1295
- # Micro::Case flow using private methods 103.297k (± 1.4%) i/s - 517.750k in 5.013254s
1299
+ # Interactor::Organizer
1300
+ # 50.731k (± 1.6%) i/s - 256.361k in 5.054694s
1301
+ # Micro::Cases.flow([])
1302
+ # 67.757k1.6%) i/s - 344.505k in 5.085681s
1303
+ # Micro::Cases::safe_flow([])
1304
+ # 67.613k (± 1.6%) i/s - 340.450k in 5.036562s
1305
+ # Micro::Case flow using `then` method
1306
+ # 69.483k (± 1.5%) i/s - 348.400k in 5.015351s
1307
+ # Micro::Case flow using private methods
1308
+ # 103.788k (± 1.0%) i/s - 528.462k in 5.092240s
1309
+ # Micro::Case flow using private methods through lambdas
1310
+ # 101.081k (± 1.2%) i/s - 512.900k in 5.074904s
1296
1311
 
1297
1312
  # Comparison:
1298
- # Micro::Case flow using private methods: 103297.4 i/s
1299
- # Micro::Case flow using `then` method: 69644.0 i/s - 1.48x (± 0.00) slower
1300
- # Micro::Cases.flow([]): 63946.7 i/s - 1.62x (± 0.00) slower
1301
- # Micro::Cases::safe_flow([]): 63047.2 i/s - 1.64x (± 0.00) slower
1302
- # Interactor::Organizer: 52958.9 i/s - 1.95x (± 0.00) slower
1313
+ # Micro::Case flow using private methods: 103787.5 i/s
1314
+ # Micro::Case flow using private methods through lambdas: 101080.6 i/s - 1.03x (± 0.00) slower
1315
+ # Micro::Case flow using `then` method: 69483.3 i/s - 1.49x (± 0.00) slower
1316
+ # Micro::Cases.flow([]): 67757.2 i/s - 1.53x (± 0.00) slower
1317
+ # Micro::Cases::safe_flow([]): 67613.3 i/s - 1.54x (± 0.00) slower
1318
+ # Interactor::Organizer: 50730.8 i/s - 2.05x (± 0.00) slower
1303
1319
  ```
1304
1320
  </details>
1305
1321
 
@@ -1308,25 +1324,39 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1308
1324
 
1309
1325
  ```ruby
1310
1326
  # Warming up --------------------------------------
1311
- # Interactor::Organizer 2.381k i/100ms
1312
- # Micro::Cases.flow([]) 12.003k i/100ms
1313
- # Micro::Cases::safe_flow([]) 12.771k i/100ms
1314
- # Micro::Case flow using `then` method 15.085k i/100ms
1315
- # Micro::Case flow using private methods 14.254k i/100ms
1316
-
1327
+ # Interactor::Organizer
1328
+ # 2.299k i/100ms
1329
+ # Micro::Cases.flow([])
1330
+ # 14.187k i/100ms
1331
+ # Micro::Cases::safe_flow([])
1332
+ # 13.609k i/100ms
1333
+ # Micro::Case flow using `then` method
1334
+ # 14.578k i/100ms
1335
+ # Micro::Case flow using private methods
1336
+ # 14.101k i/100ms
1337
+ # Micro::Case flow using private methods through lambdas
1338
+ # 13.670k i/100ms
1317
1339
  # Calculating -------------------------------------
1318
- # Interactor::Organizer 23.579k (± 3.2%) i/s - 119.050k in 5.054410s
1319
- # Micro::Cases.flow([]) 124.072k3.4%) i/s - 624.156k in 5.036618s
1320
- # Micro::Cases::safe_flow([]) 124.894k (± 3.6%) i/s - 625.779k in 5.017494s
1321
- # Micro::Case flow using `then` method 145.370k4.8%) i/s - 739.165k in 5.096972s
1322
- # Micro::Case flow using private methods 139.753k (± 5.6%) i/s - 698.446k in 5.015207s
1340
+ # Interactor::Organizer
1341
+ # 23.306k2.1%) i/s - 117.249k in 5.033171s
1342
+ # Micro::Cases.flow([])
1343
+ # 140.111k1.6%) i/s - 709.350k in 5.064041s
1344
+ # Micro::Cases::safe_flow([])
1345
+ # 139.927k (± 1.7%) i/s - 707.668k in 5.058971s
1346
+ # Micro::Case flow using `then` method
1347
+ # 146.073k (± 2.0%) i/s - 743.478k in 5.091741s
1348
+ # Micro::Case flow using private methods
1349
+ # 142.092k (± 1.5%) i/s - 719.151k in 5.062298s
1350
+ # Micro::Case flow using private methods through lambdas
1351
+ # 140.791k (± 1.2%) i/s - 710.840k in 5.049584s
1323
1352
 
1324
1353
  # Comparison:
1325
- # Micro::Case flow using `then` method: 145369.7 i/s
1326
- # Micro::Case flow using private methods: 139753.4 i/s - same-ish: difference falls within error
1327
- # Micro::Cases::safe_flow([]): 124893.7 i/s - 1.16x (± 0.00) slower
1328
- # Micro::Cases.flow([]): 124071.8 i/s - 1.17x (± 0.00) slower
1329
- # Interactor::Organizer: 23578.7 i/s - 6.17x (± 0.00) slower
1354
+ # Micro::Case flow using `then` method: 146073.0 i/s
1355
+ # Micro::Case flow using private methods: 142091.7 i/s - same-ish: difference falls within error
1356
+ # Micro::Case flow using private methods through lambdas: 140791.1 i/s - 1.04x (± 0.00) slower
1357
+ # Micro::Cases.flow([]): 140110.8 i/s - 1.04x (± 0.00) slower
1358
+ # Micro::Cases::safe_flow([]): 139926.6 i/s - 1.04x (± 0.00) slower
1359
+ # Interactor::Organizer: 23305.9 i/s - 6.27x (± 0.00) slower
1330
1360
  ```
1331
1361
  </details>
1332
1362
 
@@ -1343,24 +1373,24 @@ Check it out implementations of the same use case with different gems/abstractio
1343
1373
 
1344
1374
  ## Examples
1345
1375
 
1346
- ### 1️⃣ Rails App (API)
1376
+ ### 1️⃣ Users creation
1377
+
1378
+ > An example of a flow that defines steps to sanitize, validate, and persist its input data. It has all possible approaches to represent use cases using the `u-case` gem.
1379
+ >
1380
+ > Link: https://github.com/serradura/u-case/blob/main/examples/users_creation
1381
+
1382
+ ### 2️⃣ Rails App (API)
1347
1383
 
1348
1384
  > This project shows different kinds of architecture (one per commit), and in the last one, how to use the `Micro::Case` gem to handle the application business logic.
1349
1385
  >
1350
1386
  > Link: https://github.com/serradura/from-fat-controllers-to-use-cases
1351
1387
 
1352
- ### 2️⃣ CLI calculator
1388
+ ### 3️⃣ CLI calculator
1353
1389
 
1354
1390
  > Rake tasks to demonstrate how to handle user data, and how to use different failure types to control the program flow.
1355
1391
  >
1356
1392
  > Link: https://github.com/serradura/u-case/tree/main/examples/calculator
1357
1393
 
1358
- ### 3️⃣ Users creation
1359
-
1360
- > An example of a use case flow that defines steps to sanitize, validate, and persist its input data.
1361
- >
1362
- > Link: https://github.com/serradura/u-case/blob/main/examples/users_creation.rb
1363
-
1364
1394
  ### 4️⃣ Rescuing exceptions inside of the use cases
1365
1395
 
1366
1396
  > Link: https://github.com/serradura/u-case/blob/main/examples/rescuing_exceptions.rb
@@ -21,7 +21,7 @@ Principais objetivos deste projeto:
21
21
 
22
22
  Versão | Documentação
23
23
  --------- | -------------
24
- 3.0.0.rc7 | https://github.com/serradura/u-case/blob/main/README.md
24
+ 3.0.0.rc8 | https://github.com/serradura/u-case/blob/main/README.md
25
25
  2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
26
26
  1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
27
27
 
@@ -65,9 +65,9 @@ Versão | Documentação
65
65
  - [`Micro::Cases::Flow` (v3.0.0)](#microcasesflow-v300)
66
66
  - [Comparações](#comparações)
67
67
  - [Exemplos](#exemplos)
68
- - [1️⃣ Rails App (API)](#1️⃣-rails-app-api)
69
- - [2️⃣ CLI calculator](#2️⃣-cli-calculator)
70
- - [3️⃣ Criação de usuários](#3️⃣-criação-de-usuários)
68
+ - [1️⃣ Criação de usuários](#1️⃣-criação-de-usuários)
69
+ - [2️⃣ Rails App (API)](#2️⃣-rails-app-api)
70
+ - [3️⃣ CLI calculator](#3️⃣-cli-calculator)
71
71
  - [4️⃣ Interceptando exceções dentro dos casos de uso](#4️⃣-interceptando-exceções-dentro-dos-casos-de-uso)
72
72
  - [Desenvolvimento](#desenvolvimento)
73
73
  - [Contribuindo](#contribuindo)
@@ -78,7 +78,7 @@ Versão | Documentação
78
78
 
79
79
  | u-case | branch | ruby | activemodel |
80
80
  | -------------- | ------- | -------- | ------------- |
81
- | 3.0.0.rc7 | main | >= 2.2.0 | >= 3.2, < 6.1 |
81
+ | 3.0.0.rc8 | main | >= 2.2.0 | >= 3.2, < 6.1 |
82
82
  | 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 |
83
83
  | 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 |
84
84
 
@@ -101,7 +101,7 @@ Versão | Documentação
101
101
  Adicione essa linha ao Gemfile da sua aplicação:
102
102
 
103
103
  ```ruby
104
- gem 'u-case', '~> 3.0.0.rc7'
104
+ gem 'u-case', '~> 3.0.0.rc8'
105
105
  ```
106
106
 
107
107
  E então execute:
@@ -1180,42 +1180,42 @@ end
1180
1180
 
1181
1181
  | Gem / Abstração | Iterações por segundo | Comparação |
1182
1182
  | ----------------- | --------------------: | ----------------: |
1183
- | Dry::Monads | 139037.7 | _**O mais rápido**_ |
1184
- | **Micro::Case** | 101497.3 | 1.37x slower |
1185
- | Interactor | 30694.2 | 4.53x slower |
1186
- | Trailblazer::Operation | 14580.8 | 9.54x slower |
1187
- | Dry::Transaction | 5728.0 | 24.27x slower |
1183
+ | Dry::Monads | 141730.1 | _**O mais rápido**_ |
1184
+ | **Micro::Case** | 103541.3 | 1.37x slower |
1185
+ | Interactor | 29100.8 | 4.87x slower |
1186
+ | Trailblazer::Operation | 15031.4 | 9.43x slower |
1187
+ | Dry::Transaction | 5674.0 | 24.98x slower |
1188
1188
 
1189
1189
  <details>
1190
1190
  <summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
1191
1191
 
1192
1192
  ```ruby
1193
1193
  # Warming up --------------------------------------
1194
- # Interactor 3.056k i/100ms
1195
- # Trailblazer::Operation 1.480k i/100ms
1196
- # Dry::Monads 14.316k i/100ms
1197
- # Dry::Transaction 576.000 i/100ms
1198
- # Micro::Case 10.388k i/100ms
1199
- # Micro::Case::Strict 8.223k i/100ms
1200
- # Micro::Case::Safe 10.057k i/100ms
1194
+ # Interactor 2.915k i/100ms
1195
+ # Trailblazer::Operation 1.543k i/100ms
1196
+ # Dry::Monads 14.288k i/100ms
1197
+ # Dry::Transaction 571.000 i/100ms
1198
+ # Micro::Case 10.418k i/100ms
1199
+ # Micro::Case::Strict 8.296k i/100ms
1200
+ # Micro::Case::Safe 10.254k i/100ms
1201
1201
 
1202
1202
  # Calculating -------------------------------------
1203
- # Interactor 30.694k (± 2.3%) i/s - 155.856k in 5.080475s
1204
- # Trailblazer::Operation 14.581k3.9%) i/s - 74.000k in 5.083091s
1205
- # Dry::Monads 139.038k (± 3.0%) i/s - 701.484k in 5.049921s
1206
- # Dry::Transaction 5.728k3.6%) i/s - 28.800k in 5.034599s
1207
- # Micro::Case 100.712k3.4%) i/s - 509.012k in 5.060139s
1208
- # Micro::Case::Strict 81.513k3.4%) i/s - 411.150k in 5.049962s
1209
- # Micro::Case::Safe 101.497k3.1%) i/s - 512.907k in 5.058463s
1203
+ # Interactor 29.101k (± 2.1%) i/s - 145.750k in 5.010660s
1204
+ # Trailblazer::Operation 15.031k2.0%) i/s - 75.607k in 5.032071s
1205
+ # Dry::Monads 141.730k (± 3.1%) i/s - 714.400k in 5.045546s
1206
+ # Dry::Transaction 5.674k1.9%) i/s - 28.550k in 5.033564s
1207
+ # Micro::Case 103.541k1.6%) i/s - 520.900k in 5.032077s
1208
+ # Micro::Case::Strict 83.045k2.4%) i/s - 423.096k in 5.098031s
1209
+ # Micro::Case::Safe 101.662k1.5%) i/s - 512.700k in 5.044386s
1210
1210
 
1211
1211
  # Comparison:
1212
- # Dry::Monads: 139037.7 i/s
1213
- # Micro::Case::Safe: 101497.3 i/s - 1.37x (± 0.00) slower
1214
- # Micro::Case: 100711.6 i/s - 1.38x (± 0.00) slower
1215
- # Micro::Case::Strict: 81512.9 i/s - 1.71x (± 0.00) slower
1216
- # Interactor: 30694.2 i/s - 4.53x (± 0.00) slower
1217
- # Trailblazer::Operation: 14580.8 i/s - 9.54x (± 0.00) slower
1218
- # Dry::Transaction: 5728.0 i/s - 24.27x (± 0.00) slower
1212
+ # Dry::Monads: 141730.1 i/s
1213
+ # Micro::Case: 103541.3 i/s - 1.37x (± 0.00) slower
1214
+ # Micro::Case::Safe: 101662.2 i/s - 1.39x (± 0.00) slower
1215
+ # Micro::Case::Strict: 83044.6 i/s - 1.71x (± 0.00) slower
1216
+ # Interactor: 29100.8 i/s - 4.87x (± 0.00) slower
1217
+ # Trailblazer::Operation: 15031.4 i/s - 9.43x (± 0.00) slower
1218
+ # Dry::Transaction: 5674.0 i/s - 24.98x (± 0.00) slower
1219
1219
  ```
1220
1220
  </details>
1221
1221
 
@@ -1225,42 +1225,42 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_success_r
1225
1225
 
1226
1226
  | Gem / Abstração | Iterações por segundo | Comparação |
1227
1227
  | ----------------- | --------------------: | ----------------: |
1228
- | **Micro::Case** | 94619.6 | _**O mais rápido**_ |
1229
- | Dry::Monads | 70250.6 | 1.35x slower |
1230
- | Trailblazer::Operation | 14786.1 | 6.40x slower |
1231
- | Interactor | 13770.0 | 6.87x slower |
1232
- | Dry::Transaction | 4994.4 | 18.95x slower |
1228
+ | **Micro::Case** | 98820.8 | _**O mais rápido**_ |
1229
+ | Dry::Monads | 71329.7 | 1.39x slower |
1230
+ | Trailblazer::Operation | 15034.9 | 6.57x slower |
1231
+ | Interactor | 13958.7 | 7.08x slower |
1232
+ | Dry::Transaction | 5067.5 | 19.50x slower |
1233
1233
 
1234
1234
  <details>
1235
1235
  <summary>Mostrar o resultado completo do <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a>.</summary>
1236
1236
 
1237
1237
  ```ruby
1238
1238
  # Warming up --------------------------------------
1239
- # Interactor 1.408k i/100ms
1240
- # Trailblazer::Operation 1.492k i/100ms
1241
- # Dry::Monads 7.224k i/100ms
1242
- # Dry::Transaction 501.000 i/100ms
1243
- # Micro::Case 9.664k i/100ms
1244
- # Micro::Case::Strict 7.823k i/100ms
1245
- # Micro::Case::Safe 9.464k i/100ms
1239
+ # Interactor 1.324k i/100ms
1240
+ # Trailblazer::Operation 1.525k i/100ms
1241
+ # Dry::Monads 7.126k i/100ms
1242
+ # Dry::Transaction 499.000 i/100ms
1243
+ # Micro::Case 9.919k i/100ms
1244
+ # Micro::Case::Strict 7.837k i/100ms
1245
+ # Micro::Case::Safe 9.762k i/100ms
1246
1246
 
1247
1247
  # Calculating -------------------------------------
1248
- # Interactor 13.770k4.3%) i/s - 68.992k in 5.020330s
1249
- # Trailblazer::Operation 14.786k5.3%) i/s - 74.600k in 5.064700s
1250
- # Dry::Monads 70.251k6.7%) i/s - 353.976k in 5.063010s
1251
- # Dry::Transaction 4.994k4.0%) i/s - 25.050k in 5.023997s
1252
- # Micro::Case 94.620k3.8%) i/s - 473.536k in 5.012483s
1253
- # Micro::Case::Strict 76.059k (± 3.0%) i/s - 383.327k in 5.044482s
1254
- # Micro::Case::Safe 91.719k5.6%) i/s - 463.736k in 5.072552s
1248
+ # Interactor 13.959k2.5%) i/s - 70.172k in 5.030240s
1249
+ # Trailblazer::Operation 15.035k2.2%) i/s - 76.250k in 5.074108s
1250
+ # Dry::Monads 71.330k2.4%) i/s - 363.426k in 5.097993s
1251
+ # Dry::Transaction 5.068k1.9%) i/s - 25.449k in 5.023922s
1252
+ # Micro::Case 98.821k2.9%) i/s - 495.950k in 5.023421s
1253
+ # Micro::Case::Strict 79.936k (± 3.1%) i/s - 399.687k in 5.005435s
1254
+ # Micro::Case::Safe 98.695k1.9%) i/s - 497.862k in 5.046246s
1255
1255
 
1256
1256
  # Comparison:
1257
- # Micro::Case: 94619.6 i/s
1258
- # Micro::Case::Safe: 91719.4 i/s - same-ish: difference falls within error
1259
- # Micro::Case::Strict: 76058.7 i/s - 1.24x (± 0.00) slower
1260
- # Dry::Monads: 70250.6 i/s - 1.35x (± 0.00) slower
1261
- # Trailblazer::Operation: 14786.1 i/s - 6.40x (± 0.00) slower
1262
- # Interactor: 13770.0 i/s - 6.87x (± 0.00) slower
1263
- # Dry::Transaction: 4994.4 i/s - 18.95x (± 0.00) slower
1257
+ # Micro::Case: 98820.8 i/s
1258
+ # Micro::Case::Safe: 98695.0 i/s - same-ish: difference falls within error
1259
+ # Micro::Case::Strict: 79935.9 i/s - 1.24x (± 0.00) slower
1260
+ # Dry::Monads: 71329.7 i/s - 1.39x (± 0.00) slower
1261
+ # Trailblazer::Operation: 15034.9 i/s - 6.57x (± 0.00) slower
1262
+ # Interactor: 13958.7 i/s - 7.08x (± 0.00) slower
1263
+ # Dry::Transaction: 5067.5 i/s - 19.50x (± 0.00) slower
1264
1264
  ```
1265
1265
  </details>
1266
1266
 
@@ -1273,10 +1273,11 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1273
1273
  | Gem / Abstração | [Resultados de sucesso](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_success_result.rb#L40) | [Resultados de falha](https://github.com/serradura/u-case/blob/main/benchmarks/flow/with_failure_result.rb#L40) |
1274
1274
  | ------------------------------------------- | ----------------: | ----------------: |
1275
1275
  | Micro::Case internal flow (private methods) | _**O mais rápido**_ | _**O mais rápido**_ |
1276
- | Micro::Case `then` method | 1.48x slower | 0x slower |
1277
- | Micro::Cases.flow | 1.62x slower | 1.16x slower |
1278
- | Micro::Cases.safe_flow | 1.64x slower | 1.16x slower |
1279
- | Interactor::Organizer | 1.95x slower | 6.17x slower |
1276
+ | Micro::Case internal flow (through lambdas) | 1.03x slower | 1.04x slower |
1277
+ | Micro::Case `then` method | 1.49x slower | 0x slower |
1278
+ | Micro::Cases.flow | 1.53x slower | 1.04x slower |
1279
+ | Micro::Cases.safe_flow | 1.54x slower | 1.04x slower |
1280
+ | Interactor::Organizer | 2.05x slower | 6.27x slower |
1280
1281
 
1281
1282
  \* As gems `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` estão fora desta análise por não terem esse tipo de funcionalidade.
1282
1283
 
@@ -1285,25 +1286,40 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1285
1286
 
1286
1287
  ```ruby
1287
1288
  # Warming up --------------------------------------
1288
- # Interactor::Organizer 5.219k i/100ms
1289
- # Micro::Cases.flow([]) 6.451k i/100ms
1290
- # Micro::Cases::safe_flow([]) 6.421k i/100ms
1291
- # Micro::Case flow using `then` method 7.139k i/100ms
1292
- # Micro::Case flow using private methods 10.355k i/100ms
1289
+ # Interactor::Organizer
1290
+ # 4.837k i/100ms
1291
+ # Micro::Cases.flow([])
1292
+ # 6.755k i/100ms
1293
+ # Micro::Cases::safe_flow([])
1294
+ # 6.809k i/100ms
1295
+ # Micro::Case flow using `then` method
1296
+ # 6.968k i/100ms
1297
+ # Micro::Case flow using private methods
1298
+ # 10.362k i/100ms
1299
+ # Micro::Case flow using private methods through lambdas
1300
+ # 10.258k i/100ms
1293
1301
 
1294
1302
  # Calculating -------------------------------------
1295
- # Interactor::Organizer 52.959k (± 1.7%) i/s - 266.169k in 5.027332s
1296
- # Micro::Cases.flow([]) 63.947k (± 1.7%) i/s - 322.550k in 5.045597s
1297
- # Micro::Cases::safe_flow([]) 63.047k (± 3.1%) i/s - 321.050k in 5.097228s
1298
- # Micro::Case flow using `then` method 69.644k4.0%) i/s - 349.811k in 5.031120s
1299
- # Micro::Case flow using private methods 103.297k (± 1.4%) i/s - 517.750k in 5.013254s
1303
+ # Interactor::Organizer
1304
+ # 50.731k (± 1.6%) i/s - 256.361k in 5.054694s
1305
+ # Micro::Cases.flow([])
1306
+ # 67.757k1.6%) i/s - 344.505k in 5.085681s
1307
+ # Micro::Cases::safe_flow([])
1308
+ # 67.613k (± 1.6%) i/s - 340.450k in 5.036562s
1309
+ # Micro::Case flow using `then` method
1310
+ # 69.483k (± 1.5%) i/s - 348.400k in 5.015351s
1311
+ # Micro::Case flow using private methods
1312
+ # 103.788k (± 1.0%) i/s - 528.462k in 5.092240s
1313
+ # Micro::Case flow using private methods through lambdas
1314
+ # 101.081k (± 1.2%) i/s - 512.900k in 5.074904s
1300
1315
 
1301
1316
  # Comparison:
1302
- # Micro::Case flow using private methods: 103297.4 i/s
1303
- # Micro::Case flow using `then` method: 69644.0 i/s - 1.48x (± 0.00) slower
1304
- # Micro::Cases.flow([]): 63946.7 i/s - 1.62x (± 0.00) slower
1305
- # Micro::Cases::safe_flow([]): 63047.2 i/s - 1.64x (± 0.00) slower
1306
- # Interactor::Organizer: 52958.9 i/s - 1.95x (± 0.00) slower
1317
+ # Micro::Case flow using private methods: 103787.5 i/s
1318
+ # Micro::Case flow using private methods through lambdas: 101080.6 i/s - 1.03x (± 0.00) slower
1319
+ # Micro::Case flow using `then` method: 69483.3 i/s - 1.49x (± 0.00) slower
1320
+ # Micro::Cases.flow([]): 67757.2 i/s - 1.53x (± 0.00) slower
1321
+ # Micro::Cases::safe_flow([]): 67613.3 i/s - 1.54x (± 0.00) slower
1322
+ # Interactor::Organizer: 50730.8 i/s - 2.05x (± 0.00) slower
1307
1323
  ```
1308
1324
  </details>
1309
1325
 
@@ -1312,25 +1328,39 @@ https://github.com/serradura/u-case/blob/main/benchmarks/use_case/with_failure_r
1312
1328
 
1313
1329
  ```ruby
1314
1330
  # Warming up --------------------------------------
1315
- # Interactor::Organizer 2.381k i/100ms
1316
- # Micro::Cases.flow([]) 12.003k i/100ms
1317
- # Micro::Cases::safe_flow([]) 12.771k i/100ms
1318
- # Micro::Case flow using `then` method 15.085k i/100ms
1319
- # Micro::Case flow using private methods 14.254k i/100ms
1320
-
1331
+ # Interactor::Organizer
1332
+ # 2.299k i/100ms
1333
+ # Micro::Cases.flow([])
1334
+ # 14.187k i/100ms
1335
+ # Micro::Cases::safe_flow([])
1336
+ # 13.609k i/100ms
1337
+ # Micro::Case flow using `then` method
1338
+ # 14.578k i/100ms
1339
+ # Micro::Case flow using private methods
1340
+ # 14.101k i/100ms
1341
+ # Micro::Case flow using private methods through lambdas
1342
+ # 13.670k i/100ms
1321
1343
  # Calculating -------------------------------------
1322
- # Interactor::Organizer 23.579k (± 3.2%) i/s - 119.050k in 5.054410s
1323
- # Micro::Cases.flow([]) 124.072k3.4%) i/s - 624.156k in 5.036618s
1324
- # Micro::Cases::safe_flow([]) 124.894k (± 3.6%) i/s - 625.779k in 5.017494s
1325
- # Micro::Case flow using `then` method 145.370k4.8%) i/s - 739.165k in 5.096972s
1326
- # Micro::Case flow using private methods 139.753k (± 5.6%) i/s - 698.446k in 5.015207s
1344
+ # Interactor::Organizer
1345
+ # 23.306k2.1%) i/s - 117.249k in 5.033171s
1346
+ # Micro::Cases.flow([])
1347
+ # 140.111k1.6%) i/s - 709.350k in 5.064041s
1348
+ # Micro::Cases::safe_flow([])
1349
+ # 139.927k (± 1.7%) i/s - 707.668k in 5.058971s
1350
+ # Micro::Case flow using `then` method
1351
+ # 146.073k (± 2.0%) i/s - 743.478k in 5.091741s
1352
+ # Micro::Case flow using private methods
1353
+ # 142.092k (± 1.5%) i/s - 719.151k in 5.062298s
1354
+ # Micro::Case flow using private methods through lambdas
1355
+ # 140.791k (± 1.2%) i/s - 710.840k in 5.049584s
1327
1356
 
1328
1357
  # Comparison:
1329
- # Micro::Case flow using `then` method: 145369.7 i/s
1330
- # Micro::Case flow using private methods: 139753.4 i/s - same-ish: difference falls within error
1331
- # Micro::Cases::safe_flow([]): 124893.7 i/s - 1.16x (± 0.00) slower
1332
- # Micro::Cases.flow([]): 124071.8 i/s - 1.17x (± 0.00) slower
1333
- # Interactor::Organizer: 23578.7 i/s - 6.17x (± 0.00) slower
1358
+ # Micro::Case flow using `then` method: 146073.0 i/s
1359
+ # Micro::Case flow using private methods: 142091.7 i/s - same-ish: difference falls within error
1360
+ # Micro::Case flow using private methods through lambdas: 140791.1 i/s - 1.04x (± 0.00) slower
1361
+ # Micro::Cases.flow([]): 140110.8 i/s - 1.04x (± 0.00) slower
1362
+ # Micro::Cases::safe_flow([]): 139926.6 i/s - 1.04x (± 0.00) slower
1363
+ # Interactor::Organizer: 23305.9 i/s - 6.27x (± 0.00) slower
1334
1364
  ```
1335
1365
  </details>
1336
1366
 
@@ -1347,24 +1377,24 @@ Confira as implementações do mesmo caso de uso com diferentes gems/abstraçõe
1347
1377
 
1348
1378
  ## Exemplos
1349
1379
 
1350
- ### 1️⃣ Rails App (API)
1380
+ ### 1️⃣ Criação de usuários
1381
+
1382
+ > Um exemplo de fluxo que define etapas para higienizar, validar e persistir seus dados de entrada. Ele tem todas as abordagens possíveis para representar casos de uso com a gem `u-case`.
1383
+ >
1384
+ > Link: https://github.com/serradura/u-case/blob/main/examples/users_creation
1385
+
1386
+ ### 2️⃣ Rails App (API)
1351
1387
 
1352
1388
  > Este projeto mostra diferentes tipos de arquitetura (uma por commit), e na última, como usar a gem `Micro::Case` para lidar com a lógica de negócios da aplicação.
1353
1389
  >
1354
1390
  > Link: https://github.com/serradura/from-fat-controllers-to-use-cases
1355
1391
 
1356
- ### 2️⃣ CLI calculator
1392
+ ### 3️⃣ CLI calculator
1357
1393
 
1358
1394
  > Rake tasks para demonstrar como lidar com os dados do usuário e como usar diferentes tipos de falha para controlar o fluxo do programa.
1359
1395
  >
1360
1396
  > Link: https://github.com/serradura/u-case/tree/main/examples/calculator
1361
1397
 
1362
- ### 3️⃣ Criação de usuários
1363
-
1364
- > Um exemplo de fluxo de caso de uso que define etapas para higienizar, validar e persistir seus dados de entrada.
1365
- >
1366
- > Link: https://github.com/serradura/u-case/blob/main/examples/users_creation.rb
1367
-
1368
1398
  ### 4️⃣ Interceptando exceções dentro dos casos de uso
1369
1399
 
1370
1400
  > Link: https://github.com/serradura/u-case/blob/main/examples/rescuing_exceptions.rb
@@ -72,9 +72,7 @@ module Micro
72
72
  def self.__new__(result, arg)
73
73
  input = result.__set_transitions_accessible_attributes__(arg)
74
74
 
75
- instance = new(input)
76
- instance.__set_result__(result)
77
- instance
75
+ new(input).__set_result__(result)
78
76
  end
79
77
 
80
78
  def self.__flow_builder__
@@ -135,6 +133,8 @@ module Micro
135
133
  raise Error::ResultIsAlreadyDefined if defined?(@__result)
136
134
 
137
135
  @__result = result
136
+
137
+ self
138
138
  end
139
139
 
140
140
  private
@@ -15,7 +15,7 @@ module Micro
15
15
 
16
16
  def enable_transitions=(value)
17
17
  Micro::Case::Result.class_variable_set(
18
- :@@transition_tracking_enabled, Kind::Of::Boolean(value)
18
+ :@@transitions_enabled, Kind::Of::Boolean(value)
19
19
  )
20
20
  end
21
21
  end
@@ -7,7 +7,11 @@ module Micro
7
7
  class Result
8
8
  Kind::Types.add(self)
9
9
 
10
- @@transition_tracking_enabled = true
10
+ @@transitions_enabled = true
11
+
12
+ def self.transitions_enabled?
13
+ @@transitions_enabled
14
+ end
11
15
 
12
16
  attr_reader :type, :data, :use_case
13
17
 
@@ -142,19 +146,21 @@ module Micro
142
146
 
143
147
  @__transitions_accumulated_data.merge!(@data)
144
148
 
145
- __set_transition if @@transition_tracking_enabled
149
+ use_case_attributes = Utils.symbolize_hash_keys(@use_case.attributes)
150
+
151
+ __update_transitions_accessible_attributes(use_case_attributes)
152
+
153
+ __set_transition(use_case_attributes) if @@transitions_enabled
146
154
 
147
155
  self
148
156
  end
149
157
 
150
158
  def __set_transitions_accessible_attributes__(arg)
151
- return arg unless @@transition_tracking_enabled
159
+ return arg unless arg.is_a?(Hash)
152
160
 
153
- if arg.is_a?(Hash)
154
- attributes = Utils.symbolize_hash_keys(arg)
161
+ attributes = Utils.symbolize_hash_keys(arg)
155
162
 
156
- __update_transitions_accessible_attributes(attributes)
157
- end
163
+ __update_transitions_accessible_attributes(attributes)
158
164
  end
159
165
 
160
166
  private
@@ -165,7 +171,9 @@ module Micro
165
171
  opt ? opt.merge(@__transitions_accumulated_data) : @__transitions_accumulated_data
166
172
  )
167
173
 
168
- fn.arity.zero? ? fn.call : fn.call(input)
174
+ return fn.call if fn.arity.zero?
175
+
176
+ opt ? fn.call(**input) : fn.call(input)
169
177
  end
170
178
 
171
179
  def __call_proc(fn, expected)
@@ -197,11 +205,8 @@ module Micro
197
205
  @__transitions_accessible_attributes
198
206
  end
199
207
 
200
- def __set_transition
208
+ def __set_transition(use_case_attributes)
201
209
  use_case_class = @use_case.class
202
- use_case_attributes = Utils.symbolize_hash_keys(@use_case.attributes)
203
-
204
- __update_transitions_accessible_attributes(use_case_attributes)
205
210
 
206
211
  result = @success ? :success : :failure
207
212
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  class Case
5
- VERSION = '3.0.0.rc7'.freeze
5
+ VERSION = '3.0.0.rc8'.freeze
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-case
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc7
4
+ version: 3.0.0.rc8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kind