senro_usecaser 0.1.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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +72 -0
- data/LICENSE +21 -0
- data/README.md +1069 -0
- data/Rakefile +12 -0
- data/Steepfile +24 -0
- data/examples/RBS_GENERATION.md +16 -0
- data/examples/namespace_demo.rb +751 -0
- data/examples/order_system.rb +1279 -0
- data/examples/sig/namespace_demo.rbs +279 -0
- data/examples/sig/order_system.rbs +685 -0
- data/lefthook.yml +31 -0
- data/lib/senro_usecaser/base.rb +660 -0
- data/lib/senro_usecaser/configuration.rb +149 -0
- data/lib/senro_usecaser/container.rb +315 -0
- data/lib/senro_usecaser/error.rb +88 -0
- data/lib/senro_usecaser/provider.rb +212 -0
- data/lib/senro_usecaser/result.rb +182 -0
- data/lib/senro_usecaser/version.rb +8 -0
- data/lib/senro_usecaser.rb +155 -0
- data/sig/generated/senro_usecaser/base.rbs +365 -0
- data/sig/generated/senro_usecaser/configuration.rbs +80 -0
- data/sig/generated/senro_usecaser/container.rbs +190 -0
- data/sig/generated/senro_usecaser/error.rbs +58 -0
- data/sig/generated/senro_usecaser/provider.rbs +153 -0
- data/sig/generated/senro_usecaser/result.rbs +109 -0
- data/sig/generated/senro_usecaser/version.rbs +6 -0
- data/sig/generated/senro_usecaser.rbs +113 -0
- data/sig/overrides.rbs +16 -0
- metadata +77 -0
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
# Generated from order_system.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# ユーザーモデル
|
|
4
|
+
class User
|
|
5
|
+
# : Integer
|
|
6
|
+
attr_reader id: untyped
|
|
7
|
+
|
|
8
|
+
# : String
|
|
9
|
+
attr_reader name: untyped
|
|
10
|
+
|
|
11
|
+
# : String
|
|
12
|
+
attr_reader email: untyped
|
|
13
|
+
|
|
14
|
+
# : bool
|
|
15
|
+
attr_reader premium: untyped
|
|
16
|
+
|
|
17
|
+
# : (id: Integer, name: String, email: String, premium: bool) -> void
|
|
18
|
+
def initialize: (id: Integer, name: String, email: String, premium: bool) -> void
|
|
19
|
+
|
|
20
|
+
# : () -> bool
|
|
21
|
+
def premium?: () -> bool
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# 商品モデル
|
|
25
|
+
class Product
|
|
26
|
+
# : Integer
|
|
27
|
+
attr_reader id: untyped
|
|
28
|
+
|
|
29
|
+
# : String
|
|
30
|
+
attr_reader name: untyped
|
|
31
|
+
|
|
32
|
+
# : Integer
|
|
33
|
+
attr_reader price: untyped
|
|
34
|
+
|
|
35
|
+
# : Integer
|
|
36
|
+
attr_reader stock: untyped
|
|
37
|
+
|
|
38
|
+
# : (id: Integer, name: String, price: Integer, stock: Integer) -> void
|
|
39
|
+
def initialize: (id: Integer, name: String, price: Integer, stock: Integer) -> void
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# 注文モデル
|
|
43
|
+
class Order
|
|
44
|
+
# : Integer
|
|
45
|
+
attr_reader id: untyped
|
|
46
|
+
|
|
47
|
+
# : Integer
|
|
48
|
+
attr_reader user_id: untyped
|
|
49
|
+
|
|
50
|
+
# : Array[Integer]
|
|
51
|
+
attr_reader items: untyped
|
|
52
|
+
|
|
53
|
+
# : Integer
|
|
54
|
+
attr_reader subtotal: untyped
|
|
55
|
+
|
|
56
|
+
# : Integer
|
|
57
|
+
attr_reader tax: untyped
|
|
58
|
+
|
|
59
|
+
# : Integer
|
|
60
|
+
attr_reader discount: untyped
|
|
61
|
+
|
|
62
|
+
# : Integer
|
|
63
|
+
attr_reader total: untyped
|
|
64
|
+
|
|
65
|
+
# : String
|
|
66
|
+
attr_reader status: untyped
|
|
67
|
+
|
|
68
|
+
# : (id: Integer, user_id: Integer, items: Array[Integer], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, status: String) -> void
|
|
69
|
+
def initialize: (id: Integer, user_id: Integer, items: Array[Integer], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, status: String) -> void
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class CreateOrderOutput
|
|
73
|
+
# : (order: Order) -> void
|
|
74
|
+
def initialize: (order: Order) -> void
|
|
75
|
+
|
|
76
|
+
# : () -> Order
|
|
77
|
+
attr_reader order: untyped
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class GreetingOutput
|
|
81
|
+
# : (greeted: String) -> void
|
|
82
|
+
def initialize: (greeted: String) -> void
|
|
83
|
+
|
|
84
|
+
# : () -> String
|
|
85
|
+
attr_reader greeted: untyped
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class AccumulatedOutput
|
|
89
|
+
# : (counter: Integer, final: bool) -> void
|
|
90
|
+
def initialize: (counter: Integer, final: bool) -> void
|
|
91
|
+
|
|
92
|
+
# : () -> Integer
|
|
93
|
+
attr_reader counter: untyped
|
|
94
|
+
|
|
95
|
+
# : () -> bool
|
|
96
|
+
attr_reader final: untyped
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class UserRepository
|
|
100
|
+
# : () -> void
|
|
101
|
+
def initialize: () -> void
|
|
102
|
+
|
|
103
|
+
# : (Integer) -> User?
|
|
104
|
+
def find: (Integer) -> User?
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class ProductRepository
|
|
108
|
+
# : () -> void
|
|
109
|
+
def initialize: () -> void
|
|
110
|
+
|
|
111
|
+
# : (Integer) -> Product?
|
|
112
|
+
def find: (Integer) -> Product?
|
|
113
|
+
|
|
114
|
+
# : (Array[Integer]) -> Array[Product]
|
|
115
|
+
def find_all: (Array[Integer]) -> Array[Product]
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
class OrderRepository
|
|
119
|
+
# : () -> void
|
|
120
|
+
def initialize: () -> void
|
|
121
|
+
|
|
122
|
+
# : (user_id: Integer, items: Array[Integer], subtotal: Integer, tax: Integer, discount: Integer, total: Integer) -> Order
|
|
123
|
+
def create: (user_id: Integer, items: Array[Integer], subtotal: Integer, tax: Integer, discount: Integer, total: Integer) -> Order
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# 決済結果
|
|
127
|
+
class PaymentResult
|
|
128
|
+
# : String
|
|
129
|
+
attr_reader transaction_id: untyped
|
|
130
|
+
|
|
131
|
+
# : Time
|
|
132
|
+
attr_reader charged_at: untyped
|
|
133
|
+
|
|
134
|
+
# : (transaction_id: String, charged_at: Time) -> void
|
|
135
|
+
def initialize: (transaction_id: String, charged_at: Time) -> void
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
class PaymentService
|
|
139
|
+
# : (user: User, amount: Integer) -> PaymentResult
|
|
140
|
+
def charge: (user: User, amount: Integer) -> PaymentResult
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
class NotificationService
|
|
144
|
+
# : (to: String, subject: String, body: String) -> bool
|
|
145
|
+
def send_email: (to: String, subject: String, body: String) -> bool
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
class DiscountService
|
|
149
|
+
# : (Integer) -> Integer
|
|
150
|
+
def calculate_premium_discount: (Integer) -> Integer
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
class Logger
|
|
154
|
+
# : (String) -> void
|
|
155
|
+
def info: (String) -> void
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# コアプロバイダー: 基本サービスを登録
|
|
159
|
+
class CoreProvider < SenroUsecaser::Provider
|
|
160
|
+
# : (SenroUsecaser::Container) -> void
|
|
161
|
+
def register: (SenroUsecaser::Container) -> void
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# インフラプロバイダー: リポジトリを登録
|
|
165
|
+
class InfrastructureProvider < SenroUsecaser::Provider
|
|
166
|
+
# : (SenroUsecaser::Container) -> void
|
|
167
|
+
def register: (SenroUsecaser::Container) -> void
|
|
168
|
+
|
|
169
|
+
# : (SenroUsecaser::Container) -> void
|
|
170
|
+
def after_boot: (SenroUsecaser::Container) -> void
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# サービスプロバイダー: ビジネスサービスを登録
|
|
174
|
+
class ServiceProvider < SenroUsecaser::Provider
|
|
175
|
+
# : (SenroUsecaser::Container) -> void
|
|
176
|
+
def register: (SenroUsecaser::Container) -> void
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# 開発環境用プロバイダー: 開発環境でのみ有効
|
|
180
|
+
class DevelopmentProvider < SenroUsecaser::Provider
|
|
181
|
+
# : (SenroUsecaser::Container) -> void
|
|
182
|
+
def register: (SenroUsecaser::Container) -> void
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# ユーザー検証
|
|
186
|
+
class ValidateUserUseCase < SenroUsecaser::Base
|
|
187
|
+
class Input
|
|
188
|
+
# : (user_id: Integer, product_ids: Array[Integer], **untyped) -> void
|
|
189
|
+
def initialize: (user_id: Integer, product_ids: Array[Integer], **untyped) -> void
|
|
190
|
+
|
|
191
|
+
# : () -> Integer
|
|
192
|
+
attr_reader user_id: untyped
|
|
193
|
+
|
|
194
|
+
# : () -> Array[Integer]
|
|
195
|
+
attr_reader product_ids: untyped
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
class Output
|
|
199
|
+
# : (user: User, product_ids: Array[Integer], **untyped) -> void
|
|
200
|
+
def initialize: (user: User, product_ids: Array[Integer], **untyped) -> void
|
|
201
|
+
|
|
202
|
+
# : () -> User
|
|
203
|
+
attr_reader user: untyped
|
|
204
|
+
|
|
205
|
+
# : () -> Array[Integer]
|
|
206
|
+
attr_reader product_ids: untyped
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def user_repository: () -> UserRepository
|
|
210
|
+
|
|
211
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
212
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# 商品検証と在庫チェック
|
|
216
|
+
class ValidateProductsUseCase < SenroUsecaser::Base
|
|
217
|
+
class Input
|
|
218
|
+
# : (user: User, product_ids: Array[Integer], **untyped) -> void
|
|
219
|
+
def initialize: (user: User, product_ids: Array[Integer], **untyped) -> void
|
|
220
|
+
|
|
221
|
+
# : () -> User
|
|
222
|
+
attr_reader user: untyped
|
|
223
|
+
|
|
224
|
+
# : () -> Array[Integer]
|
|
225
|
+
attr_reader product_ids: untyped
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
class Output
|
|
229
|
+
# : (user: User, items: Array[Product], subtotal: Integer, **untyped) -> void
|
|
230
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, **untyped) -> void
|
|
231
|
+
|
|
232
|
+
# : () -> User
|
|
233
|
+
attr_reader user: untyped
|
|
234
|
+
|
|
235
|
+
# : () -> Array[Product]
|
|
236
|
+
attr_reader items: untyped
|
|
237
|
+
|
|
238
|
+
# : () -> Integer
|
|
239
|
+
attr_reader subtotal: untyped
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def product_repository: () -> ProductRepository
|
|
243
|
+
|
|
244
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
245
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# 税金計算
|
|
249
|
+
class CalculateTaxUseCase < SenroUsecaser::Base
|
|
250
|
+
class Input
|
|
251
|
+
# : (user: User, items: Array[Product], subtotal: Integer, **untyped) -> void
|
|
252
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, **untyped) -> void
|
|
253
|
+
|
|
254
|
+
# : () -> User
|
|
255
|
+
attr_reader user: untyped
|
|
256
|
+
|
|
257
|
+
# : () -> Array[Product]
|
|
258
|
+
attr_reader items: untyped
|
|
259
|
+
|
|
260
|
+
# : () -> Integer
|
|
261
|
+
attr_reader subtotal: untyped
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
class Output
|
|
265
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, **untyped) -> void
|
|
266
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, **untyped) -> void
|
|
267
|
+
|
|
268
|
+
# : () -> User
|
|
269
|
+
attr_reader user: untyped
|
|
270
|
+
|
|
271
|
+
# : () -> Array[Product]
|
|
272
|
+
attr_reader items: untyped
|
|
273
|
+
|
|
274
|
+
# : () -> Integer
|
|
275
|
+
attr_reader subtotal: untyped
|
|
276
|
+
|
|
277
|
+
# : () -> Integer
|
|
278
|
+
attr_reader tax: untyped
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
282
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# プレミアム会員割引
|
|
286
|
+
class ApplyPremiumDiscountUseCase < SenroUsecaser::Base
|
|
287
|
+
class Input
|
|
288
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, **untyped) -> void
|
|
289
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, **untyped) -> void
|
|
290
|
+
|
|
291
|
+
# : () -> User
|
|
292
|
+
attr_reader user: untyped
|
|
293
|
+
|
|
294
|
+
# : () -> Array[Product]
|
|
295
|
+
attr_reader items: untyped
|
|
296
|
+
|
|
297
|
+
# : () -> Integer
|
|
298
|
+
attr_reader subtotal: untyped
|
|
299
|
+
|
|
300
|
+
# : () -> Integer
|
|
301
|
+
attr_reader tax: untyped
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
class Output
|
|
305
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, **untyped) -> void
|
|
306
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, **untyped) -> void
|
|
307
|
+
|
|
308
|
+
# : () -> User
|
|
309
|
+
attr_reader user: untyped
|
|
310
|
+
|
|
311
|
+
# : () -> Array[Product]
|
|
312
|
+
attr_reader items: untyped
|
|
313
|
+
|
|
314
|
+
# : () -> Integer
|
|
315
|
+
attr_reader subtotal: untyped
|
|
316
|
+
|
|
317
|
+
# : () -> Integer
|
|
318
|
+
attr_reader tax: untyped
|
|
319
|
+
|
|
320
|
+
# : () -> Integer
|
|
321
|
+
attr_reader discount: untyped
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def discount_service: () -> DiscountService
|
|
325
|
+
|
|
326
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
327
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# 合計計算
|
|
331
|
+
class CalculateTotalUseCase < SenroUsecaser::Base
|
|
332
|
+
class Input
|
|
333
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, ?discount: Integer, **untyped) -> void
|
|
334
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, ?discount: Integer, **untyped) -> void
|
|
335
|
+
|
|
336
|
+
# : () -> User
|
|
337
|
+
attr_reader user: untyped
|
|
338
|
+
|
|
339
|
+
# : () -> Array[Product]
|
|
340
|
+
attr_reader items: untyped
|
|
341
|
+
|
|
342
|
+
# : () -> Integer
|
|
343
|
+
attr_reader subtotal: untyped
|
|
344
|
+
|
|
345
|
+
# : () -> Integer
|
|
346
|
+
attr_reader tax: untyped
|
|
347
|
+
|
|
348
|
+
# : () -> Integer
|
|
349
|
+
attr_reader discount: untyped
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
class Output
|
|
353
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, **untyped) -> void
|
|
354
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, **untyped) -> void
|
|
355
|
+
|
|
356
|
+
# : () -> User
|
|
357
|
+
attr_reader user: untyped
|
|
358
|
+
|
|
359
|
+
# : () -> Array[Product]
|
|
360
|
+
attr_reader items: untyped
|
|
361
|
+
|
|
362
|
+
# : () -> Integer
|
|
363
|
+
attr_reader subtotal: untyped
|
|
364
|
+
|
|
365
|
+
# : () -> Integer
|
|
366
|
+
attr_reader tax: untyped
|
|
367
|
+
|
|
368
|
+
# : () -> Integer
|
|
369
|
+
attr_reader discount: untyped
|
|
370
|
+
|
|
371
|
+
# : () -> Integer
|
|
372
|
+
attr_reader total: untyped
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
376
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# 決済処理
|
|
380
|
+
class ProcessPaymentUseCase < SenroUsecaser::Base
|
|
381
|
+
class Input
|
|
382
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, **untyped) -> void
|
|
383
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, **untyped) -> void
|
|
384
|
+
|
|
385
|
+
# : () -> User
|
|
386
|
+
attr_reader user: untyped
|
|
387
|
+
|
|
388
|
+
# : () -> Array[Product]
|
|
389
|
+
attr_reader items: untyped
|
|
390
|
+
|
|
391
|
+
# : () -> Integer
|
|
392
|
+
attr_reader subtotal: untyped
|
|
393
|
+
|
|
394
|
+
# : () -> Integer
|
|
395
|
+
attr_reader tax: untyped
|
|
396
|
+
|
|
397
|
+
# : () -> Integer
|
|
398
|
+
attr_reader discount: untyped
|
|
399
|
+
|
|
400
|
+
# : () -> Integer
|
|
401
|
+
attr_reader total: untyped
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
class Output
|
|
405
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, payment: PaymentResult, **untyped) -> void
|
|
406
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, payment: PaymentResult, **untyped) -> void
|
|
407
|
+
|
|
408
|
+
# : () -> User
|
|
409
|
+
attr_reader user: untyped
|
|
410
|
+
|
|
411
|
+
# : () -> Array[Product]
|
|
412
|
+
attr_reader items: untyped
|
|
413
|
+
|
|
414
|
+
# : () -> Integer
|
|
415
|
+
attr_reader subtotal: untyped
|
|
416
|
+
|
|
417
|
+
# : () -> Integer
|
|
418
|
+
attr_reader tax: untyped
|
|
419
|
+
|
|
420
|
+
# : () -> Integer
|
|
421
|
+
attr_reader discount: untyped
|
|
422
|
+
|
|
423
|
+
# : () -> Integer
|
|
424
|
+
attr_reader total: untyped
|
|
425
|
+
|
|
426
|
+
# : () -> PaymentResult
|
|
427
|
+
attr_reader payment: untyped
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def payment_service: () -> PaymentService
|
|
431
|
+
|
|
432
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
433
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# 注文作成
|
|
437
|
+
class CreateOrderRecordUseCase < SenroUsecaser::Base
|
|
438
|
+
class Input
|
|
439
|
+
# : (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, **untyped) -> void
|
|
440
|
+
def initialize: (user: User, items: Array[Product], subtotal: Integer, tax: Integer, discount: Integer, total: Integer, **untyped) -> void
|
|
441
|
+
|
|
442
|
+
# : () -> User
|
|
443
|
+
attr_reader user: untyped
|
|
444
|
+
|
|
445
|
+
# : () -> Array[Product]
|
|
446
|
+
attr_reader items: untyped
|
|
447
|
+
|
|
448
|
+
# : () -> Integer
|
|
449
|
+
attr_reader subtotal: untyped
|
|
450
|
+
|
|
451
|
+
# : () -> Integer
|
|
452
|
+
attr_reader tax: untyped
|
|
453
|
+
|
|
454
|
+
# : () -> Integer
|
|
455
|
+
attr_reader discount: untyped
|
|
456
|
+
|
|
457
|
+
# : () -> Integer
|
|
458
|
+
attr_reader total: untyped
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
class Output
|
|
462
|
+
# : (user: User, order: Order, **untyped) -> void
|
|
463
|
+
def initialize: (user: User, order: Order, **untyped) -> void
|
|
464
|
+
|
|
465
|
+
# : () -> User
|
|
466
|
+
attr_reader user: untyped
|
|
467
|
+
|
|
468
|
+
# : () -> Order
|
|
469
|
+
attr_reader order: untyped
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
def order_repository: () -> OrderRepository
|
|
473
|
+
|
|
474
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
475
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
# 通知送信
|
|
479
|
+
class SendOrderNotificationUseCase < SenroUsecaser::Base
|
|
480
|
+
class Input
|
|
481
|
+
# : (user: User, order: Order, **untyped) -> void
|
|
482
|
+
def initialize: (user: User, order: Order, **untyped) -> void
|
|
483
|
+
|
|
484
|
+
# : () -> User
|
|
485
|
+
attr_reader user: untyped
|
|
486
|
+
|
|
487
|
+
# : () -> Order
|
|
488
|
+
attr_reader order: untyped
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
class Output
|
|
492
|
+
# : (user: User, order: Order, notified: bool, **untyped) -> void
|
|
493
|
+
def initialize: (user: User, order: Order, notified: bool, **untyped) -> void
|
|
494
|
+
|
|
495
|
+
# : () -> User
|
|
496
|
+
attr_reader user: untyped
|
|
497
|
+
|
|
498
|
+
# : () -> Order
|
|
499
|
+
attr_reader order: untyped
|
|
500
|
+
|
|
501
|
+
# : () -> bool
|
|
502
|
+
attr_reader notified: untyped
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
def notification_service: () -> NotificationService
|
|
506
|
+
|
|
507
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
508
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
# パイプライン最終出力をラップ
|
|
512
|
+
class WrapOrderOutputUseCase < SenroUsecaser::Base
|
|
513
|
+
class Input
|
|
514
|
+
# : (order: Order, **untyped) -> void
|
|
515
|
+
def initialize: (order: Order, **untyped) -> void
|
|
516
|
+
|
|
517
|
+
# : () -> Order
|
|
518
|
+
attr_reader order: untyped
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
# : (Input) -> SenroUsecaser::Result[CreateOrderOutput]
|
|
522
|
+
def call: (Input) -> SenroUsecaser::Result[CreateOrderOutput]
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
# ログ記録用 Extension
|
|
526
|
+
module LoggingExtension
|
|
527
|
+
# : (Hash[Symbol, untyped]) -> void
|
|
528
|
+
def self.before: (Hash[Symbol, untyped]) -> void
|
|
529
|
+
|
|
530
|
+
# : (Hash[Symbol, untyped], SenroUsecaser::Result[untyped]) -> void
|
|
531
|
+
def self.after: (Hash[Symbol, untyped], SenroUsecaser::Result[untyped]) -> void
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
# 注文作成パイプライン
|
|
535
|
+
class CreateOrderUseCase < SenroUsecaser::Base
|
|
536
|
+
class Input
|
|
537
|
+
# : (user_id: Integer, product_ids: Array[Integer], **untyped) -> void
|
|
538
|
+
def initialize: (user_id: Integer, product_ids: Array[Integer], **untyped) -> void
|
|
539
|
+
|
|
540
|
+
# : () -> Integer
|
|
541
|
+
attr_reader user_id: untyped
|
|
542
|
+
|
|
543
|
+
# : () -> Array[Integer]
|
|
544
|
+
attr_reader product_ids: untyped
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
def self.call: (Input, ?container: SenroUsecaser::Container) -> SenroUsecaser::Result[CreateOrderOutput]
|
|
548
|
+
|
|
549
|
+
# : (Hash[Symbol, untyped]) -> bool
|
|
550
|
+
def premium_user?: (Hash[Symbol, untyped]) -> bool
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
# リクエストごとに current_user を注入するパターン
|
|
554
|
+
class CurrentUserAwareUseCase < SenroUsecaser::Base
|
|
555
|
+
def current_user: () -> User
|
|
556
|
+
|
|
557
|
+
def logger: () -> Logger
|
|
558
|
+
|
|
559
|
+
# : (?untyped, **untyped) -> SenroUsecaser::Result[GreetingOutput]
|
|
560
|
+
def call: (?untyped, **untyped) -> SenroUsecaser::Result[GreetingOutput]
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
class Step1 < SenroUsecaser::Base
|
|
564
|
+
class Input
|
|
565
|
+
# : (initial: String, **untyped) -> void
|
|
566
|
+
def initialize: (initial: String, **untyped) -> void
|
|
567
|
+
|
|
568
|
+
# : () -> String
|
|
569
|
+
attr_reader initial: untyped
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
class Output
|
|
573
|
+
# : (step1_data: String, counter: Integer, **untyped) -> void
|
|
574
|
+
def initialize: (step1_data: String, counter: Integer, **untyped) -> void
|
|
575
|
+
|
|
576
|
+
# : () -> String
|
|
577
|
+
attr_reader step1_data: untyped
|
|
578
|
+
|
|
579
|
+
# : () -> Integer
|
|
580
|
+
attr_reader counter: untyped
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
584
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
class Step2 < SenroUsecaser::Base
|
|
588
|
+
class Input
|
|
589
|
+
# : (step1_data: String, counter: Integer, **untyped) -> void
|
|
590
|
+
def initialize: (step1_data: String, counter: Integer, **untyped) -> void
|
|
591
|
+
|
|
592
|
+
# : () -> String
|
|
593
|
+
attr_reader step1_data: untyped
|
|
594
|
+
|
|
595
|
+
# : () -> Integer
|
|
596
|
+
attr_reader counter: untyped
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
class Output
|
|
600
|
+
# : (step1_data: String, step2_data: String, counter: Integer, **untyped) -> void
|
|
601
|
+
def initialize: (step1_data: String, step2_data: String, counter: Integer, **untyped) -> void
|
|
602
|
+
|
|
603
|
+
# : () -> String
|
|
604
|
+
attr_reader step1_data: untyped
|
|
605
|
+
|
|
606
|
+
# : () -> String
|
|
607
|
+
attr_reader step2_data: untyped
|
|
608
|
+
|
|
609
|
+
# : () -> Integer
|
|
610
|
+
attr_reader counter: untyped
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
614
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
class Step3 < SenroUsecaser::Base
|
|
618
|
+
class Input
|
|
619
|
+
# : (step1_data: String, step2_data: String, counter: Integer, **untyped) -> void
|
|
620
|
+
def initialize: (step1_data: String, step2_data: String, counter: Integer, **untyped) -> void
|
|
621
|
+
|
|
622
|
+
# : () -> String
|
|
623
|
+
attr_reader step1_data: untyped
|
|
624
|
+
|
|
625
|
+
# : () -> String
|
|
626
|
+
attr_reader step2_data: untyped
|
|
627
|
+
|
|
628
|
+
# : () -> Integer
|
|
629
|
+
attr_reader counter: untyped
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
class Output
|
|
633
|
+
# : (step1_data: String, step2_data: String, step3_data: String, counter: Integer, final: bool, **untyped) -> void
|
|
634
|
+
def initialize: (step1_data: String, step2_data: String, step3_data: String, counter: Integer, final: bool, **untyped) -> void
|
|
635
|
+
|
|
636
|
+
# : () -> String
|
|
637
|
+
attr_reader step1_data: untyped
|
|
638
|
+
|
|
639
|
+
# : () -> String
|
|
640
|
+
attr_reader step2_data: untyped
|
|
641
|
+
|
|
642
|
+
# : () -> String
|
|
643
|
+
attr_reader step3_data: untyped
|
|
644
|
+
|
|
645
|
+
# : () -> Integer
|
|
646
|
+
attr_reader counter: untyped
|
|
647
|
+
|
|
648
|
+
# : () -> bool
|
|
649
|
+
attr_reader final: untyped
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
# : (Input) -> SenroUsecaser::Result[Output]
|
|
653
|
+
def call: (Input) -> SenroUsecaser::Result[Output]
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
class WrapAccumulatedOutputUseCase < SenroUsecaser::Base
|
|
657
|
+
class Input
|
|
658
|
+
# : (counter: Integer, final: bool, **untyped) -> void
|
|
659
|
+
def initialize: (counter: Integer, final: bool, **untyped) -> void
|
|
660
|
+
|
|
661
|
+
# : () -> Integer
|
|
662
|
+
attr_reader counter: untyped
|
|
663
|
+
|
|
664
|
+
# : () -> bool
|
|
665
|
+
attr_reader final: untyped
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
# : (Input) -> SenroUsecaser::Result[AccumulatedOutput]
|
|
669
|
+
def call: (Input) -> SenroUsecaser::Result[AccumulatedOutput]
|
|
670
|
+
end
|
|
671
|
+
|
|
672
|
+
class AccumulatedContextDemo < SenroUsecaser::Base
|
|
673
|
+
class Input
|
|
674
|
+
# : (initial: String, **untyped) -> void
|
|
675
|
+
def initialize: (initial: String, **untyped) -> void
|
|
676
|
+
|
|
677
|
+
# : () -> String
|
|
678
|
+
attr_reader initial: untyped
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
def self.call: (Input, ?container: SenroUsecaser::Container) -> SenroUsecaser::Result[AccumulatedOutput]
|
|
682
|
+
|
|
683
|
+
# : (untyped) -> bool
|
|
684
|
+
def check_accumulated: (untyped) -> bool
|
|
685
|
+
end
|
data/lefthook.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Lefthook configuration
|
|
2
|
+
# https://github.com/evilmartians/lefthook
|
|
3
|
+
|
|
4
|
+
pre-commit:
|
|
5
|
+
parallel: true
|
|
6
|
+
commands:
|
|
7
|
+
rubocop:
|
|
8
|
+
glob: "*.rb"
|
|
9
|
+
run: bundle exec rubocop {staged_files}
|
|
10
|
+
steep:
|
|
11
|
+
glob: "*.rb"
|
|
12
|
+
run: bundle exec steep check
|
|
13
|
+
|
|
14
|
+
pre-push:
|
|
15
|
+
parallel: true
|
|
16
|
+
commands:
|
|
17
|
+
rspec:
|
|
18
|
+
run: bundle exec rspec
|
|
19
|
+
skip:
|
|
20
|
+
- merge
|
|
21
|
+
- rebase
|
|
22
|
+
rubocop:
|
|
23
|
+
run: bundle exec rubocop
|
|
24
|
+
skip:
|
|
25
|
+
- merge
|
|
26
|
+
- rebase
|
|
27
|
+
steep:
|
|
28
|
+
run: bundle exec steep check
|
|
29
|
+
skip:
|
|
30
|
+
- merge
|
|
31
|
+
- rebase
|