servus 0.1.3 → 0.1.5

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.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/commands/check-docs.md +1 -0
  3. data/.claude/commands/consistency-check.md +1 -0
  4. data/.claude/commands/fine-tooth-comb.md +1 -0
  5. data/.claude/commands/red-green-refactor.md +5 -0
  6. data/.claude/settings.json +15 -0
  7. data/.rubocop.yml +18 -2
  8. data/.yardopts +6 -0
  9. data/CHANGELOG.md +47 -0
  10. data/CLAUDE.md +10 -0
  11. data/IDEAS.md +5 -0
  12. data/READme.md +300 -47
  13. data/Rakefile +33 -0
  14. data/builds/servus-0.1.3.gem +0 -0
  15. data/builds/servus-0.1.4.gem +0 -0
  16. data/builds/servus-0.1.5.gem +0 -0
  17. data/docs/core/1_overview.md +77 -0
  18. data/docs/core/2_architecture.md +120 -0
  19. data/docs/core/3_service_objects.md +121 -0
  20. data/docs/current_focus.md +569 -0
  21. data/docs/features/1_schema_validation.md +119 -0
  22. data/docs/features/2_error_handling.md +121 -0
  23. data/docs/features/3_async_execution.md +81 -0
  24. data/docs/features/4_logging.md +64 -0
  25. data/docs/features/5_event_bus.md +244 -0
  26. data/docs/guides/1_common_patterns.md +90 -0
  27. data/docs/guides/2_migration_guide.md +175 -0
  28. data/docs/integration/1_configuration.md +104 -0
  29. data/docs/integration/2_testing.md +287 -0
  30. data/docs/integration/3_rails_integration.md +99 -0
  31. data/docs/yard/Servus/Base.html +1645 -0
  32. data/docs/yard/Servus/Config.html +582 -0
  33. data/docs/yard/Servus/Extensions/Async/Call.html +400 -0
  34. data/docs/yard/Servus/Extensions/Async/Errors/AsyncError.html +140 -0
  35. data/docs/yard/Servus/Extensions/Async/Errors/JobEnqueueError.html +154 -0
  36. data/docs/yard/Servus/Extensions/Async/Errors/ServiceNotFoundError.html +154 -0
  37. data/docs/yard/Servus/Extensions/Async/Errors.html +128 -0
  38. data/docs/yard/Servus/Extensions/Async/Ext.html +119 -0
  39. data/docs/yard/Servus/Extensions/Async/Job.html +310 -0
  40. data/docs/yard/Servus/Extensions/Async.html +141 -0
  41. data/docs/yard/Servus/Extensions.html +117 -0
  42. data/docs/yard/Servus/Generators/ServiceGenerator.html +261 -0
  43. data/docs/yard/Servus/Generators.html +115 -0
  44. data/docs/yard/Servus/Helpers/ControllerHelpers.html +457 -0
  45. data/docs/yard/Servus/Helpers.html +115 -0
  46. data/docs/yard/Servus/Railtie.html +134 -0
  47. data/docs/yard/Servus/Support/Errors/AuthenticationError.html +287 -0
  48. data/docs/yard/Servus/Support/Errors/BadRequestError.html +283 -0
  49. data/docs/yard/Servus/Support/Errors/ForbiddenError.html +284 -0
  50. data/docs/yard/Servus/Support/Errors/InternalServerError.html +283 -0
  51. data/docs/yard/Servus/Support/Errors/NotFoundError.html +284 -0
  52. data/docs/yard/Servus/Support/Errors/ServiceError.html +489 -0
  53. data/docs/yard/Servus/Support/Errors/ServiceUnavailableError.html +290 -0
  54. data/docs/yard/Servus/Support/Errors/UnauthorizedError.html +200 -0
  55. data/docs/yard/Servus/Support/Errors/UnprocessableEntityError.html +288 -0
  56. data/docs/yard/Servus/Support/Errors/ValidationError.html +200 -0
  57. data/docs/yard/Servus/Support/Errors.html +140 -0
  58. data/docs/yard/Servus/Support/Logger.html +856 -0
  59. data/docs/yard/Servus/Support/Rescuer/BlockContext.html +585 -0
  60. data/docs/yard/Servus/Support/Rescuer/CallOverride.html +257 -0
  61. data/docs/yard/Servus/Support/Rescuer/ClassMethods.html +343 -0
  62. data/docs/yard/Servus/Support/Rescuer.html +267 -0
  63. data/docs/yard/Servus/Support/Response.html +574 -0
  64. data/docs/yard/Servus/Support/Validator.html +1150 -0
  65. data/docs/yard/Servus/Support.html +119 -0
  66. data/docs/yard/Servus/Testing/ExampleBuilders.html +523 -0
  67. data/docs/yard/Servus/Testing/ExampleExtractor.html +578 -0
  68. data/docs/yard/Servus/Testing.html +142 -0
  69. data/docs/yard/Servus.html +343 -0
  70. data/docs/yard/_index.html +535 -0
  71. data/docs/yard/class_list.html +54 -0
  72. data/docs/yard/css/common.css +1 -0
  73. data/docs/yard/css/full_list.css +58 -0
  74. data/docs/yard/css/style.css +503 -0
  75. data/docs/yard/file.1_common_patterns.html +154 -0
  76. data/docs/yard/file.1_configuration.html +115 -0
  77. data/docs/yard/file.1_overview.html +142 -0
  78. data/docs/yard/file.1_schema_validation.html +188 -0
  79. data/docs/yard/file.2_architecture.html +157 -0
  80. data/docs/yard/file.2_error_handling.html +190 -0
  81. data/docs/yard/file.2_migration_guide.html +242 -0
  82. data/docs/yard/file.2_testing.html +227 -0
  83. data/docs/yard/file.3_async_execution.html +145 -0
  84. data/docs/yard/file.3_rails_integration.html +160 -0
  85. data/docs/yard/file.3_service_objects.html +191 -0
  86. data/docs/yard/file.4_logging.html +135 -0
  87. data/docs/yard/file.ErrorHandling.html +190 -0
  88. data/docs/yard/file.READme.html +674 -0
  89. data/docs/yard/file.architecture.html +157 -0
  90. data/docs/yard/file.async_execution.html +145 -0
  91. data/docs/yard/file.common_patterns.html +154 -0
  92. data/docs/yard/file.configuration.html +115 -0
  93. data/docs/yard/file.error_handling.html +190 -0
  94. data/docs/yard/file.logging.html +135 -0
  95. data/docs/yard/file.migration_guide.html +242 -0
  96. data/docs/yard/file.overview.html +142 -0
  97. data/docs/yard/file.rails_integration.html +160 -0
  98. data/docs/yard/file.schema_validation.html +188 -0
  99. data/docs/yard/file.service_objects.html +191 -0
  100. data/docs/yard/file.testing.html +227 -0
  101. data/docs/yard/file_list.html +119 -0
  102. data/docs/yard/frames.html +22 -0
  103. data/docs/yard/index.html +674 -0
  104. data/docs/yard/js/app.js +344 -0
  105. data/docs/yard/js/full_list.js +242 -0
  106. data/docs/yard/js/jquery.js +4 -0
  107. data/docs/yard/method_list.html +542 -0
  108. data/docs/yard/top-level-namespace.html +110 -0
  109. data/lib/generators/servus/event_handler/event_handler_generator.rb +59 -0
  110. data/lib/generators/servus/event_handler/templates/handler.rb.erb +86 -0
  111. data/lib/generators/servus/event_handler/templates/handler_spec.rb.erb +48 -0
  112. data/lib/generators/servus/service/service_generator.rb +68 -1
  113. data/lib/generators/servus/service/templates/arguments.json.erb +19 -10
  114. data/lib/generators/servus/service/templates/result.json.erb +8 -2
  115. data/lib/generators/servus/service/templates/service.rb.erb +102 -5
  116. data/lib/generators/servus/service/templates/service_spec.rb.erb +67 -6
  117. data/lib/servus/base.rb +275 -58
  118. data/lib/servus/config.rb +83 -17
  119. data/lib/servus/event_handler.rb +275 -0
  120. data/lib/servus/events/bus.rb +137 -0
  121. data/lib/servus/events/emitter.rb +162 -0
  122. data/lib/servus/events/errors.rb +10 -0
  123. data/lib/servus/extensions/async/call.rb +50 -18
  124. data/lib/servus/extensions/async/errors.rb +23 -3
  125. data/lib/servus/extensions/async/ext.rb +10 -2
  126. data/lib/servus/extensions/async/job.rb +30 -9
  127. data/lib/servus/helpers/controller_helpers.rb +73 -37
  128. data/lib/servus/railtie.rb +16 -0
  129. data/lib/servus/support/errors.rb +135 -45
  130. data/lib/servus/support/rescuer.rb +189 -36
  131. data/lib/servus/support/response.rb +49 -7
  132. data/lib/servus/support/validator.rb +147 -19
  133. data/lib/servus/testing/example_builders.rb +133 -0
  134. data/lib/servus/testing/example_extractor.rb +309 -0
  135. data/lib/servus/testing/matchers.rb +88 -0
  136. data/lib/servus/testing.rb +19 -0
  137. data/lib/servus/version.rb +1 -1
  138. data/lib/servus.rb +6 -0
  139. metadata +135 -19
@@ -0,0 +1,1645 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Servus::Base
8
+
9
+ &mdash; Servus | Service Object Framework
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Servus::Base";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span>
41
+ &raquo;
42
+ <span class="title">Base</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Servus::Base
63
+ <span class="abstract note title">Abstract</span>
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Servus::Base</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <dl>
91
+ <dt>Includes:</dt>
92
+ <dd><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Support::Errors</a></span>, <span class='object_link'><a href="Support/Rescuer.html" title="Servus::Support::Rescuer (module)">Support::Rescuer</a></span></dd>
93
+ </dl>
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <dl>
101
+ <dt>Defined in:</dt>
102
+ <dd>lib/servus/base.rb</dd>
103
+ </dl>
104
+
105
+ </div>
106
+
107
+ <h2>Overview</h2><div class="docstring">
108
+ <div class="discussion">
109
+ <div class="note abstract">
110
+ <strong>This class is abstract.</strong>
111
+ <div class='inline'><p>Subclass and implement initialize and call methods to create a service</p>
112
+ </div>
113
+ </div>
114
+ <p>Base class for all service objects in the Servus framework.</p>
115
+
116
+ <p>This class provides the foundational functionality for implementing the Service Object pattern,
117
+ including automatic validation, logging, benchmarking, and error handling.</p>
118
+
119
+
120
+ </div>
121
+ </div>
122
+ <div class="tags">
123
+
124
+ <div class="examples">
125
+ <h4 class="tag_title">Examples:</h4>
126
+
127
+
128
+ <h5 class="example_title"><div class='inline'><p>Creating a basic service</p>
129
+ </div></h5>
130
+
131
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>Services</span><span class='op'>::</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'>Base</span>
132
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>user:</span><span class='comma'>,</span> <span class='label'>amount:</span><span class='comma'>,</span> <span class='label'>payment_method:</span><span class='rparen'>)</span>
133
+ <span class='ivar'>@user</span> <span class='op'>=</span> <span class='id identifier rubyid_user'>user</span>
134
+ <span class='ivar'>@amount</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span>
135
+ <span class='ivar'>@payment_method</span> <span class='op'>=</span> <span class='id identifier rubyid_payment_method'>payment_method</span>
136
+ <span class='kw'>end</span>
137
+
138
+ <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
139
+ <span class='kw'>return</span> <span class='id identifier rubyid_failure'>failure</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid amount</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@amount</span> <span class='op'>&lt;=</span> <span class='int'>0</span>
140
+
141
+ <span class='id identifier rubyid_transaction'>transaction</span> <span class='op'>=</span> <span class='id identifier rubyid_charge_payment'>charge_payment</span>
142
+ <span class='id identifier rubyid_success'>success</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>transaction_id:</span> <span class='id identifier rubyid_transaction'>transaction</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
143
+ <span class='kw'>end</span>
144
+
145
+ <span class='id identifier rubyid_private'>private</span>
146
+
147
+ <span class='kw'>def</span> <span class='id identifier rubyid_charge_payment'>charge_payment</span>
148
+ <span class='comment'># Payment processing logic
149
+ </span> <span class='kw'>end</span>
150
+ <span class='kw'>end</span></code></pre>
151
+
152
+
153
+ <h5 class="example_title"><div class='inline'><p>Using a service</p>
154
+ </div></h5>
155
+
156
+ <pre class="example code"><code><span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>Services</span><span class='op'>::</span><span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span>
157
+ <span class='label'>user:</span> <span class='id identifier rubyid_current_user'>current_user</span><span class='comma'>,</span>
158
+ <span class='label'>amount:</span> <span class='int'>100</span><span class='comma'>,</span>
159
+ <span class='label'>payment_method:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>credit_card</span><span class='tstring_end'>&quot;</span></span>
160
+ <span class='rparen'>)</span>
161
+
162
+ <span class='kw'>if</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_success?'>success?</span>
163
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Transaction ID: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:transaction_id</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
164
+ <span class='kw'>else</span>
165
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Error: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
166
+ <span class='kw'>end</span></code></pre>
167
+
168
+ </div>
169
+
170
+
171
+ <p class="tag_title">See Also:</p>
172
+ <ul class="see">
173
+
174
+ <li><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Support::Response</a></span></li>
175
+
176
+ <li><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Support::Errors</a></span></li>
177
+
178
+ </ul>
179
+
180
+ </div>
181
+
182
+ <h2>
183
+ Constant Summary
184
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
185
+ </h2>
186
+
187
+ <dl class="constants">
188
+
189
+ <dt id="Logger-constant" class="">Logger =
190
+ <div class="docstring">
191
+ <div class="discussion">
192
+ <p>Support class aliases</p>
193
+
194
+
195
+ </div>
196
+ </div>
197
+ <div class="tags">
198
+
199
+
200
+ </div>
201
+ </dt>
202
+ <dd><pre class="code"><span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Logger.html" title="Servus::Support::Logger (class)">Logger</a></span></span></pre></dd>
203
+
204
+ <dt id="Response-constant" class="">Response =
205
+
206
+ </dt>
207
+ <dd><pre class="code"><span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Response</a></span></span></pre></dd>
208
+
209
+ <dt id="Validator-constant" class="">Validator =
210
+
211
+ </dt>
212
+ <dd><pre class="code"><span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Validator.html" title="Servus::Support::Validator (class)">Validator</a></span></span></pre></dd>
213
+
214
+ </dl>
215
+
216
+
217
+
218
+
219
+
220
+ <h2>Class Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
221
+ <ul class="summary">
222
+
223
+ <li class="public ">
224
+ <span class="summary_signature">
225
+
226
+ <a href="#arguments_schema-class_method" title="arguments_schema (class method)">.<strong>arguments_schema</strong> &#x21d2; Hash<sup>?</sup> </a>
227
+
228
+
229
+
230
+ </span>
231
+
232
+
233
+
234
+
235
+ <span class="note title readonly">readonly</span>
236
+
237
+
238
+
239
+
240
+
241
+
242
+ <span class="private note title">private</span>
243
+
244
+
245
+ <span class="summary_desc"><div class='inline'><p>Returns the arguments schema defined via the schema DSL method.</p>
246
+ </div></span>
247
+
248
+ </li>
249
+
250
+
251
+ <li class="public ">
252
+ <span class="summary_signature">
253
+
254
+ <a href="#result_schema-class_method" title="result_schema (class method)">.<strong>result_schema</strong> &#x21d2; Hash<sup>?</sup> </a>
255
+
256
+
257
+
258
+ </span>
259
+
260
+
261
+
262
+
263
+ <span class="note title readonly">readonly</span>
264
+
265
+
266
+
267
+
268
+
269
+
270
+ <span class="private note title">private</span>
271
+
272
+
273
+ <span class="summary_desc"><div class='inline'><p>Returns the result schema defined via the schema DSL method.</p>
274
+ </div></span>
275
+
276
+ </li>
277
+
278
+
279
+ </ul>
280
+
281
+
282
+
283
+
284
+
285
+ <h2>
286
+ Class Method Summary
287
+ <small><a href="#" class="summary_toggle">collapse</a></small>
288
+ </h2>
289
+
290
+ <ul class="summary">
291
+
292
+ <li class="public ">
293
+ <span class="summary_signature">
294
+
295
+ <a href="#after_call-class_method" title="after_call (class method)">.<strong>after_call</strong>(result) &#x21d2; void </a>
296
+
297
+
298
+
299
+ </span>
300
+
301
+
302
+
303
+
304
+
305
+
306
+ <span class="private note title">private</span>
307
+
308
+
309
+ <span class="summary_desc"><div class='inline'><p>Executes post-call hooks including result validation.</p>
310
+ </div></span>
311
+
312
+ </li>
313
+
314
+
315
+ <li class="public ">
316
+ <span class="summary_signature">
317
+
318
+ <a href="#before_call-class_method" title="before_call (class method)">.<strong>before_call</strong>(args) &#x21d2; void </a>
319
+
320
+
321
+
322
+ </span>
323
+
324
+
325
+
326
+
327
+
328
+
329
+ <span class="private note title">private</span>
330
+
331
+
332
+ <span class="summary_desc"><div class='inline'><p>Executes pre-call hooks including logging and argument validation.</p>
333
+ </div></span>
334
+
335
+ </li>
336
+
337
+
338
+ <li class="public ">
339
+ <span class="summary_signature">
340
+
341
+ <a href="#benchmark-class_method" title="benchmark (class method)">.<strong>benchmark</strong>(**_args) &#x21d2; Servus::Support::Response </a>
342
+
343
+
344
+
345
+ </span>
346
+
347
+
348
+
349
+
350
+
351
+
352
+ <span class="private note title">private</span>
353
+
354
+
355
+ <span class="summary_desc"><div class='inline'><p>Measures service execution time and logs the result.</p>
356
+ </div></span>
357
+
358
+ </li>
359
+
360
+
361
+ <li class="public ">
362
+ <span class="summary_signature">
363
+
364
+ <a href="#call-class_method" title="call (class method)">.<strong>call</strong>(**args) &#x21d2; Servus::Support::Response </a>
365
+
366
+
367
+
368
+ </span>
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+ <span class="summary_desc"><div class='inline'><p>Executes the service with automatic validation, logging, and benchmarking.</p>
379
+ </div></span>
380
+
381
+ </li>
382
+
383
+
384
+ <li class="public ">
385
+ <span class="summary_signature">
386
+
387
+ <a href="#schema-class_method" title="schema (class method)">.<strong>schema</strong>(arguments: nil, result: nil) &#x21d2; void </a>
388
+
389
+
390
+
391
+ </span>
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+ <span class="summary_desc"><div class='inline'><p>Defines schema validation rules for the service&#39;s arguments and/or result.</p>
402
+ </div></span>
403
+
404
+ </li>
405
+
406
+
407
+ </ul>
408
+
409
+ <h2>
410
+ Instance Method Summary
411
+ <small><a href="#" class="summary_toggle">collapse</a></small>
412
+ </h2>
413
+
414
+ <ul class="summary">
415
+
416
+ <li class="public ">
417
+ <span class="summary_signature">
418
+
419
+ <a href="#error!-instance_method" title="#error! (instance method)">#<strong>error!</strong>(message = nil, type: Servus::Support::Errors::ServiceError) &#x21d2; void </a>
420
+
421
+
422
+
423
+ </span>
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+ <span class="summary_desc"><div class='inline'><p>Logs an error and raises an exception, halting service execution.</p>
434
+ </div></span>
435
+
436
+ </li>
437
+
438
+
439
+ <li class="public ">
440
+ <span class="summary_signature">
441
+
442
+ <a href="#failure-instance_method" title="#failure (instance method)">#<strong>failure</strong>(message = nil, type: Servus::Support::Errors::ServiceError) &#x21d2; Servus::Support::Response </a>
443
+
444
+
445
+
446
+ </span>
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
456
+ <span class="summary_desc"><div class='inline'><p>Creates a failure response with an error.</p>
457
+ </div></span>
458
+
459
+ </li>
460
+
461
+
462
+ <li class="public ">
463
+ <span class="summary_signature">
464
+
465
+ <a href="#success-instance_method" title="#success (instance method)">#<strong>success</strong>(data) &#x21d2; Servus::Support::Response </a>
466
+
467
+
468
+
469
+ </span>
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+ <span class="summary_desc"><div class='inline'><p>Creates a successful response with the provided data.</p>
480
+ </div></span>
481
+
482
+ </li>
483
+
484
+
485
+ </ul>
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="Support/Rescuer.html" title="Servus::Support::Rescuer (module)">Support::Rescuer</a></span></h3>
498
+ <p class="inherited"><span class='object_link'><a href="Support/Rescuer.html#included-class_method" title="Servus::Support::Rescuer.included (method)">included</a></span></p>
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+ <div id="class_attr_details" class="attr_details">
507
+ <h2>Class Attribute Details</h2>
508
+
509
+
510
+ <span id=""></span>
511
+ <div class="method_details first">
512
+ <h3 class="signature first" id="arguments_schema-class_method">
513
+
514
+ .<strong>arguments_schema</strong> &#x21d2; <tt>Hash</tt><sup>?</sup> <span class="extras">(readonly)</span>
515
+
516
+
517
+
518
+
519
+
520
+ </h3><div class="docstring">
521
+ <div class="discussion">
522
+ <p class="note private">
523
+ <strong>This method is part of a private API.</strong>
524
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
525
+ </p>
526
+ <p>Returns the arguments schema defined via the schema DSL method.</p>
527
+
528
+
529
+ </div>
530
+ </div>
531
+ <div class="tags">
532
+
533
+ <p class="tag_title">Returns:</p>
534
+ <ul class="return">
535
+
536
+ <li>
537
+
538
+
539
+ <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
540
+
541
+
542
+
543
+ &mdash;
544
+ <div class='inline'><p>the arguments schema or nil if not defined</p>
545
+ </div>
546
+
547
+ </li>
548
+
549
+ </ul>
550
+
551
+ </div><table class="source_code">
552
+ <tr>
553
+ <td>
554
+ <pre class="lines">
555
+
556
+
557
+ 236
558
+ 237
559
+ 238</pre>
560
+ </td>
561
+ <td>
562
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 236</span>
563
+
564
+ <span class='kw'>def</span> <span class='id identifier rubyid_arguments_schema'>arguments_schema</span>
565
+ <span class='ivar'>@arguments_schema</span>
566
+ <span class='kw'>end</span></pre>
567
+ </td>
568
+ </tr>
569
+ </table>
570
+ </div>
571
+
572
+
573
+ <span id=""></span>
574
+ <div class="method_details ">
575
+ <h3 class="signature " id="result_schema-class_method">
576
+
577
+ .<strong>result_schema</strong> &#x21d2; <tt>Hash</tt><sup>?</sup> <span class="extras">(readonly)</span>
578
+
579
+
580
+
581
+
582
+
583
+ </h3><div class="docstring">
584
+ <div class="discussion">
585
+ <p class="note private">
586
+ <strong>This method is part of a private API.</strong>
587
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
588
+ </p>
589
+ <p>Returns the result schema defined via the schema DSL method.</p>
590
+
591
+
592
+ </div>
593
+ </div>
594
+ <div class="tags">
595
+
596
+ <p class="tag_title">Returns:</p>
597
+ <ul class="return">
598
+
599
+ <li>
600
+
601
+
602
+ <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
603
+
604
+
605
+
606
+ &mdash;
607
+ <div class='inline'><p>the result schema or nil if not defined</p>
608
+ </div>
609
+
610
+ </li>
611
+
612
+ </ul>
613
+
614
+ </div><table class="source_code">
615
+ <tr>
616
+ <td>
617
+ <pre class="lines">
618
+
619
+
620
+ 242
621
+ 243
622
+ 244</pre>
623
+ </td>
624
+ <td>
625
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 242</span>
626
+
627
+ <span class='kw'>def</span> <span class='id identifier rubyid_result_schema'>result_schema</span>
628
+ <span class='ivar'>@result_schema</span>
629
+ <span class='kw'>end</span></pre>
630
+ </td>
631
+ </tr>
632
+ </table>
633
+ </div>
634
+
635
+ </div>
636
+
637
+
638
+ <div id="class_method_details" class="method_details_list">
639
+ <h2>Class Method Details</h2>
640
+
641
+
642
+ <div class="method_details first">
643
+ <h3 class="signature first" id="after_call-class_method">
644
+
645
+ .<strong>after_call</strong>(result) &#x21d2; <tt>void</tt>
646
+
647
+
648
+
649
+
650
+
651
+ </h3><div class="docstring">
652
+ <div class="discussion">
653
+ <p class="note private">
654
+ <strong>This method is part of a private API.</strong>
655
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
656
+ </p>
657
+ <p class="note returns_void">This method returns an undefined value.</p><p>Executes post-call hooks including result validation.</p>
658
+
659
+ <p>This method is automatically called after service execution completes and handles:</p>
660
+
661
+ <ul>
662
+ <li>Validating the result data against RESULT_SCHEMA (if defined)</li>
663
+ </ul>
664
+
665
+
666
+ </div>
667
+ </div>
668
+ <div class="tags">
669
+ <p class="tag_title">Parameters:</p>
670
+ <ul class="param">
671
+
672
+ <li>
673
+
674
+ <span class='name'>result</span>
675
+
676
+
677
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
678
+
679
+
680
+
681
+ &mdash;
682
+ <div class='inline'><p>the response returned from the service</p>
683
+ </div>
684
+
685
+ </li>
686
+
687
+ </ul>
688
+
689
+ <p class="tag_title">Raises:</p>
690
+ <ul class="raise">
691
+
692
+ <li>
693
+
694
+
695
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Errors/ValidationError.html" title="Servus::Support::Errors::ValidationError (class)">Servus::Support::Errors::ValidationError</a></span></tt>)</span>
696
+
697
+
698
+
699
+ &mdash;
700
+ <div class='inline'><p>if result data fails validation</p>
701
+ </div>
702
+
703
+ </li>
704
+
705
+ </ul>
706
+
707
+ </div><table class="source_code">
708
+ <tr>
709
+ <td>
710
+ <pre class="lines">
711
+
712
+
713
+ 270
714
+ 271
715
+ 272</pre>
716
+ </td>
717
+ <td>
718
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 270</span>
719
+
720
+ <span class='kw'>def</span> <span class='id identifier rubyid_after_call'>after_call</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span>
721
+ <span class='const'><span class='object_link'><a href="#Validator-constant" title="Servus::Base::Validator (constant)">Validator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_validate_result!'>validate_result!</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span>
722
+ <span class='kw'>end</span></pre>
723
+ </td>
724
+ </tr>
725
+ </table>
726
+ </div>
727
+
728
+ <div class="method_details ">
729
+ <h3 class="signature " id="before_call-class_method">
730
+
731
+ .<strong>before_call</strong>(args) &#x21d2; <tt>void</tt>
732
+
733
+
734
+
735
+
736
+
737
+ </h3><div class="docstring">
738
+ <div class="discussion">
739
+ <p class="note private">
740
+ <strong>This method is part of a private API.</strong>
741
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
742
+ </p>
743
+ <p class="note returns_void">This method returns an undefined value.</p><p>Executes pre-call hooks including logging and argument validation.</p>
744
+
745
+ <p>This method is automatically called before service execution and handles:</p>
746
+
747
+ <ul>
748
+ <li>Logging the service call with arguments</li>
749
+ <li>Validating arguments against ARGUMENTS_SCHEMA (if defined)</li>
750
+ </ul>
751
+
752
+
753
+ </div>
754
+ </div>
755
+ <div class="tags">
756
+ <p class="tag_title">Parameters:</p>
757
+ <ul class="param">
758
+
759
+ <li>
760
+
761
+ <span class='name'>args</span>
762
+
763
+
764
+ <span class='type'>(<tt>Hash</tt>)</span>
765
+
766
+
767
+
768
+ &mdash;
769
+ <div class='inline'><p>keyword arguments being passed to the service</p>
770
+ </div>
771
+
772
+ </li>
773
+
774
+ </ul>
775
+
776
+ <p class="tag_title">Raises:</p>
777
+ <ul class="raise">
778
+
779
+ <li>
780
+
781
+
782
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Errors/ValidationError.html" title="Servus::Support::Errors::ValidationError (class)">Servus::Support::Errors::ValidationError</a></span></tt>)</span>
783
+
784
+
785
+
786
+ &mdash;
787
+ <div class='inline'><p>if arguments fail validation</p>
788
+ </div>
789
+
790
+ </li>
791
+
792
+ </ul>
793
+
794
+ </div><table class="source_code">
795
+ <tr>
796
+ <td>
797
+ <pre class="lines">
798
+
799
+
800
+ 255
801
+ 256
802
+ 257
803
+ 258</pre>
804
+ </td>
805
+ <td>
806
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 255</span>
807
+
808
+ <span class='kw'>def</span> <span class='id identifier rubyid_before_call'>before_call</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
809
+ <span class='const'><span class='object_link'><a href="#Logger-constant" title="Servus::Base::Logger (constant)">Logger</a></span></span><span class='period'>.</span><span class='id identifier rubyid_log_call'>log_call</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
810
+ <span class='const'><span class='object_link'><a href="#Validator-constant" title="Servus::Base::Validator (constant)">Validator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_validate_arguments!'>validate_arguments!</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
811
+ <span class='kw'>end</span></pre>
812
+ </td>
813
+ </tr>
814
+ </table>
815
+ </div>
816
+
817
+ <div class="method_details ">
818
+ <h3 class="signature " id="benchmark-class_method">
819
+
820
+ .<strong>benchmark</strong>(**_args) &#x21d2; <tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>
821
+
822
+
823
+
824
+
825
+
826
+ </h3><div class="docstring">
827
+ <div class="discussion">
828
+ <p class="note private">
829
+ <strong>This method is part of a private API.</strong>
830
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
831
+ </p>
832
+ <p>Measures service execution time and logs the result.</p>
833
+
834
+ <p>This method wraps the service execution to capture timing metrics.
835
+ The duration is logged along with the success/failure status of the service.</p>
836
+
837
+
838
+ </div>
839
+ </div>
840
+ <div class="tags">
841
+ <p class="tag_title">Parameters:</p>
842
+ <ul class="param">
843
+
844
+ <li>
845
+
846
+ <span class='name'>_args</span>
847
+
848
+
849
+ <span class='type'>(<tt>Hash</tt>)</span>
850
+
851
+
852
+
853
+ &mdash;
854
+ <div class='inline'><p>keyword arguments (unused, kept for method signature compatibility)</p>
855
+ </div>
856
+
857
+ </li>
858
+
859
+ </ul>
860
+
861
+ <p class="tag_title">Yield Returns:</p>
862
+ <ul class="yieldreturn">
863
+
864
+ <li>
865
+
866
+
867
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
868
+
869
+
870
+
871
+ &mdash;
872
+ <div class='inline'><p>the result from executing the service</p>
873
+ </div>
874
+
875
+ </li>
876
+
877
+ </ul>
878
+ <p class="tag_title">Returns:</p>
879
+ <ul class="return">
880
+
881
+ <li>
882
+
883
+
884
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
885
+
886
+
887
+
888
+ &mdash;
889
+ <div class='inline'><p>the service execution result</p>
890
+ </div>
891
+
892
+ </li>
893
+
894
+ </ul>
895
+
896
+ </div><table class="source_code">
897
+ <tr>
898
+ <td>
899
+ <pre class="lines">
900
+
901
+
902
+ 284
903
+ 285
904
+ 286
905
+ 287
906
+ 288
907
+ 289
908
+ 290
909
+ 291
910
+ 292</pre>
911
+ </td>
912
+ <td>
913
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 284</span>
914
+
915
+ <span class='kw'>def</span> <span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid__args'>_args</span><span class='rparen'>)</span>
916
+ <span class='id identifier rubyid_start_time'>start_time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_utc'>utc</span>
917
+ <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='kw'>yield</span>
918
+ <span class='id identifier rubyid_duration'>duration</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_utc'>utc</span> <span class='op'>-</span> <span class='id identifier rubyid_start_time'>start_time</span>
919
+
920
+ <span class='const'><span class='object_link'><a href="#Logger-constant" title="Servus::Base::Logger (constant)">Logger</a></span></span><span class='period'>.</span><span class='id identifier rubyid_log_result'>log_result</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='comma'>,</span> <span class='id identifier rubyid_duration'>duration</span><span class='rparen'>)</span>
921
+
922
+ <span class='id identifier rubyid_result'>result</span>
923
+ <span class='kw'>end</span></pre>
924
+ </td>
925
+ </tr>
926
+ </table>
927
+ </div>
928
+
929
+ <div class="method_details ">
930
+ <h3 class="signature " id="call-class_method">
931
+
932
+ .<strong>call</strong>(**args) &#x21d2; <tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>
933
+
934
+
935
+
936
+
937
+
938
+ </h3><div class="docstring">
939
+ <div class="discussion">
940
+ <p>Executes the service with automatic validation, logging, and benchmarking.</p>
941
+
942
+ <p>This is the primary entry point for executing services. It handles the complete
943
+ service lifecycle including:</p>
944
+
945
+ <ul>
946
+ <li>Input argument validation against schema</li>
947
+ <li>Service instantiation</li>
948
+ <li>Execution timing/benchmarking</li>
949
+ <li>Result validation against schema</li>
950
+ <li>Automatic logging of calls, results, and errors</li>
951
+ </ul>
952
+
953
+
954
+ </div>
955
+ </div>
956
+ <div class="tags">
957
+
958
+ <div class="examples">
959
+ <h4 class="tag_title">Examples:</h4>
960
+
961
+
962
+ <h5 class="example_title"><div class='inline'><p>Successful execution</p>
963
+ </div></h5>
964
+
965
+ <pre class="example code"><code><span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>MyService</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='label'>user_id:</span> <span class='int'>123</span><span class='comma'>,</span> <span class='label'>amount:</span> <span class='int'>50</span><span class='rparen'>)</span>
966
+ <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_success?'>success?</span> <span class='comment'># =&gt; true
967
+ </span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span> <span class='comment'># =&gt; { transaction_id: &quot;abc123&quot; }</span></code></pre>
968
+
969
+
970
+ <h5 class="example_title"><div class='inline'><p>Failed execution</p>
971
+ </div></h5>
972
+
973
+ <pre class="example code"><code><span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>MyService</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='label'>user_id:</span> <span class='int'>123</span><span class='comma'>,</span> <span class='label'>amount:</span> <span class='op'>-</span><span class='int'>10</span><span class='rparen'>)</span>
974
+ <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_success?'>success?</span> <span class='comment'># =&gt; false
975
+ </span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span> <span class='comment'># =&gt; &quot;Amount must be positive&quot;</span></code></pre>
976
+
977
+ </div>
978
+ <p class="tag_title">Parameters:</p>
979
+ <ul class="param">
980
+
981
+ <li>
982
+
983
+ <span class='name'>args</span>
984
+
985
+
986
+ <span class='type'>(<tt>Hash</tt>)</span>
987
+
988
+
989
+
990
+ &mdash;
991
+ <div class='inline'><p>keyword arguments passed to the service&#39;s initialize method</p>
992
+ </div>
993
+
994
+ </li>
995
+
996
+ </ul>
997
+
998
+ <p class="tag_title">Returns:</p>
999
+ <ul class="return">
1000
+
1001
+ <li>
1002
+
1003
+
1004
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
1005
+
1006
+
1007
+
1008
+ &mdash;
1009
+ <div class='inline'><p>response object with success status and data or error</p>
1010
+ </div>
1011
+
1012
+ </li>
1013
+
1014
+ </ul>
1015
+ <p class="tag_title">Raises:</p>
1016
+ <ul class="raise">
1017
+
1018
+ <li>
1019
+
1020
+
1021
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Errors/ValidationError.html" title="Servus::Support::Errors::ValidationError (class)">Servus::Support::Errors::ValidationError</a></span></tt>)</span>
1022
+
1023
+
1024
+
1025
+ &mdash;
1026
+ <div class='inline'><p>if input arguments fail schema validation</p>
1027
+ </div>
1028
+
1029
+ </li>
1030
+
1031
+ <li>
1032
+
1033
+
1034
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Errors/ValidationError.html" title="Servus::Support::Errors::ValidationError (class)">Servus::Support::Errors::ValidationError</a></span></tt>)</span>
1035
+
1036
+
1037
+
1038
+ &mdash;
1039
+ <div class='inline'><p>if result data fails schema validation</p>
1040
+ </div>
1041
+
1042
+ </li>
1043
+
1044
+ <li>
1045
+
1046
+
1047
+ <span class='type'>(<tt>StandardError</tt>)</span>
1048
+
1049
+
1050
+
1051
+ &mdash;
1052
+ <div class='inline'><p>if an uncaught exception occurs during execution</p>
1053
+ </div>
1054
+
1055
+ </li>
1056
+
1057
+ </ul>
1058
+
1059
+ <p class="tag_title">See Also:</p>
1060
+ <ul class="see">
1061
+
1062
+ <li>#initialize</li>
1063
+
1064
+ <li>#call</li>
1065
+
1066
+ </ul>
1067
+
1068
+ </div><table class="source_code">
1069
+ <tr>
1070
+ <td>
1071
+ <pre class="lines">
1072
+
1073
+
1074
+ 175
1075
+ 176
1076
+ 177
1077
+ 178
1078
+ 179
1079
+ 180
1080
+ 181
1081
+ 182
1082
+ 183
1083
+ 184
1084
+ 185
1085
+ 186
1086
+ 187</pre>
1087
+ </td>
1088
+ <td>
1089
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 175</span>
1090
+
1091
+ <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
1092
+ <span class='id identifier rubyid_before_call'>before_call</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
1093
+ <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='rbrace'>}</span>
1094
+ <span class='id identifier rubyid_after_call'>after_call</span><span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span>
1095
+
1096
+ <span class='id identifier rubyid_result'>result</span>
1097
+ <span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors/ValidationError.html" title="Servus::Support::Errors::ValidationError (class)">ValidationError</a></span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1098
+ <span class='const'><span class='object_link'><a href="#Logger-constant" title="Servus::Base::Logger (constant)">Logger</a></span></span><span class='period'>.</span><span class='id identifier rubyid_log_validation_error'>log_validation_error</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
1099
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_e'>e</span>
1100
+ <span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1101
+ <span class='const'><span class='object_link'><a href="#Logger-constant" title="Servus::Base::Logger (constant)">Logger</a></span></span><span class='period'>.</span><span class='id identifier rubyid_log_exception'>log_exception</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
1102
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_e'>e</span>
1103
+ <span class='kw'>end</span></pre>
1104
+ </td>
1105
+ </tr>
1106
+ </table>
1107
+ </div>
1108
+
1109
+ <div class="method_details ">
1110
+ <h3 class="signature " id="schema-class_method">
1111
+
1112
+ .<strong>schema</strong>(arguments: nil, result: nil) &#x21d2; <tt>void</tt>
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+ </h3><div class="docstring">
1119
+ <div class="discussion">
1120
+ <p class="note returns_void">This method returns an undefined value.</p><p>Defines schema validation rules for the service&#39;s arguments and/or result.</p>
1121
+
1122
+ <p>This method provides a clean DSL for specifying JSON schemas that will be used
1123
+ to validate service inputs and outputs. Schemas defined via this method take
1124
+ precedence over ARGUMENTS_SCHEMA and RESULT_SCHEMA constants. The next major
1125
+ version will deprecate those constants in favor of this DSL.</p>
1126
+
1127
+
1128
+ </div>
1129
+ </div>
1130
+ <div class="tags">
1131
+
1132
+ <div class="examples">
1133
+ <h4 class="tag_title">Examples:</h4>
1134
+
1135
+
1136
+ <h5 class="example_title"><div class='inline'><p>Defining both arguments and result schemas</p>
1137
+ </div></h5>
1138
+
1139
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>ProcessPayment</span><span class='op'>::</span><span class='const'>Service</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Servus::Base (class)">Base</a></span></span>
1140
+ <span class='id identifier rubyid_schema'>schema</span><span class='lparen'>(</span>
1141
+ <span class='label'>arguments:</span> <span class='lbrace'>{</span>
1142
+ <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>object</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
1143
+ <span class='label'>required:</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>user_id</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>amount</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
1144
+ <span class='label'>properties:</span> <span class='lbrace'>{</span>
1145
+ <span class='label'>user_id:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>integer</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
1146
+ <span class='label'>amount:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>number</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>minimum:</span> <span class='float'>0.01</span> <span class='rbrace'>}</span>
1147
+ <span class='rbrace'>}</span>
1148
+ <span class='rbrace'>}</span><span class='comma'>,</span>
1149
+ <span class='label'>result:</span> <span class='lbrace'>{</span>
1150
+ <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>object</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
1151
+ <span class='label'>required:</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>transaction_id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
1152
+ <span class='label'>properties:</span> <span class='lbrace'>{</span>
1153
+ <span class='label'>transaction_id:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>string</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span>
1154
+ <span class='rbrace'>}</span>
1155
+ <span class='rbrace'>}</span>
1156
+ <span class='rparen'>)</span>
1157
+ <span class='kw'>end</span></code></pre>
1158
+
1159
+
1160
+ <h5 class="example_title"><div class='inline'><p>Defining only arguments schema</p>
1161
+ </div></h5>
1162
+
1163
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>SendEmail</span><span class='op'>::</span><span class='const'>Service</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Servus::Base (class)">Base</a></span></span>
1164
+ <span class='id identifier rubyid_schema'>schema</span> <span class='label'>arguments:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>object</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>required:</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>email</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>subject</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
1165
+ <span class='kw'>end</span></code></pre>
1166
+
1167
+ </div>
1168
+ <p class="tag_title">Parameters:</p>
1169
+ <ul class="param">
1170
+
1171
+ <li>
1172
+
1173
+ <span class='name'>arguments</span>
1174
+
1175
+
1176
+ <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
1177
+
1178
+
1179
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1180
+
1181
+
1182
+ &mdash;
1183
+ <div class='inline'><p>JSON schema for validating service arguments</p>
1184
+ </div>
1185
+
1186
+ </li>
1187
+
1188
+ <li>
1189
+
1190
+ <span class='name'>result</span>
1191
+
1192
+
1193
+ <span class='type'>(<tt>Hash</tt>, <tt>nil</tt>)</span>
1194
+
1195
+
1196
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1197
+
1198
+
1199
+ &mdash;
1200
+ <div class='inline'><p>JSON schema for validating service result data</p>
1201
+ </div>
1202
+
1203
+ </li>
1204
+
1205
+ </ul>
1206
+
1207
+
1208
+ <p class="tag_title">See Also:</p>
1209
+ <ul class="see">
1210
+
1211
+ <li><span class='object_link'><a href="Support/Validator.html" title="Servus::Support::Validator (class)">Support::Validator</a></span></li>
1212
+
1213
+ </ul>
1214
+
1215
+ </div><table class="source_code">
1216
+ <tr>
1217
+ <td>
1218
+ <pre class="lines">
1219
+
1220
+
1221
+ 227
1222
+ 228
1223
+ 229
1224
+ 230</pre>
1225
+ </td>
1226
+ <td>
1227
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 227</span>
1228
+
1229
+ <span class='kw'>def</span> <span class='id identifier rubyid_schema'>schema</span><span class='lparen'>(</span><span class='label'>arguments:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>result:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1230
+ <span class='ivar'>@arguments_schema</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_with_indifferent_access'>with_indifferent_access</span> <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span>
1231
+ <span class='ivar'>@result_schema</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_with_indifferent_access'>with_indifferent_access</span> <span class='kw'>if</span> <span class='id identifier rubyid_result'>result</span>
1232
+ <span class='kw'>end</span></pre>
1233
+ </td>
1234
+ </tr>
1235
+ </table>
1236
+ </div>
1237
+
1238
+ </div>
1239
+
1240
+ <div id="instance_method_details" class="method_details_list">
1241
+ <h2>Instance Method Details</h2>
1242
+
1243
+
1244
+ <div class="method_details first">
1245
+ <h3 class="signature first" id="error!-instance_method">
1246
+
1247
+ #<strong>error!</strong>(message = nil, type: Servus::Support::Errors::ServiceError) &#x21d2; <tt>void</tt>
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+ </h3><div class="docstring">
1254
+ <div class="discussion">
1255
+
1256
+ <div class="note notetag">
1257
+ <strong>Note:</strong>
1258
+ <div class='inline'><p>Prefer <span class='object_link'><a href="#failure-instance_method" title="Servus::Base#failure (method)">#failure</a></span> for expected error conditions. Use this for exceptional cases.</p>
1259
+ </div>
1260
+ </div>
1261
+
1262
+ <p class="note returns_void">This method returns an undefined value.</p><p>Logs an error and raises an exception, halting service execution.</p>
1263
+
1264
+ <p>Use this method when you need to immediately halt execution with an exception
1265
+ rather than returning a failure response. The error is automatically logged before
1266
+ the exception is raised.</p>
1267
+
1268
+
1269
+ </div>
1270
+ </div>
1271
+ <div class="tags">
1272
+
1273
+ <div class="examples">
1274
+ <h4 class="tag_title">Examples:</h4>
1275
+
1276
+
1277
+ <h5 class="example_title"><div class='inline'><p>Raising an error with custom message</p>
1278
+ </div></h5>
1279
+
1280
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
1281
+ <span class='id identifier rubyid_error!'>error!</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Critical system failure</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_system_down?'>system_down?</span>
1282
+ <span class='kw'>end</span></code></pre>
1283
+
1284
+
1285
+ <h5 class="example_title"><div class='inline'><p>Raising with specific error type</p>
1286
+ </div></h5>
1287
+
1288
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
1289
+ <span class='id identifier rubyid_error!'>error!</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unauthorized access</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors/UnauthorizedError.html" title="Servus::Support::Errors::UnauthorizedError (class)">UnauthorizedError</a></span></span><span class='rparen'>)</span>
1290
+ <span class='kw'>end</span></code></pre>
1291
+
1292
+ </div>
1293
+ <p class="tag_title">Parameters:</p>
1294
+ <ul class="param">
1295
+
1296
+ <li>
1297
+
1298
+ <span class='name'>message</span>
1299
+
1300
+
1301
+ <span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
1302
+
1303
+
1304
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1305
+
1306
+
1307
+ &mdash;
1308
+ <div class='inline'><p>error message for the exception (uses default if nil)</p>
1309
+ </div>
1310
+
1311
+ </li>
1312
+
1313
+ <li>
1314
+
1315
+ <span class='name'>type</span>
1316
+
1317
+
1318
+ <span class='type'>(<tt>Class</tt>)</span>
1319
+
1320
+
1321
+ <em class="default">(defaults to: <tt>Servus::Support::Errors::ServiceError</tt>)</em>
1322
+
1323
+
1324
+ &mdash;
1325
+ <div class='inline'><p>error class to raise (must inherit from ServiceError)</p>
1326
+ </div>
1327
+
1328
+ </li>
1329
+
1330
+ </ul>
1331
+
1332
+ <p class="tag_title">Raises:</p>
1333
+ <ul class="raise">
1334
+
1335
+ <li>
1336
+
1337
+
1338
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Errors/ServiceError.html" title="Servus::Support::Errors::ServiceError (class)">Servus::Support::Errors::ServiceError</a></span></tt>)</span>
1339
+
1340
+
1341
+
1342
+ &mdash;
1343
+ <div class='inline'><p>the specified error type</p>
1344
+ </div>
1345
+
1346
+ </li>
1347
+
1348
+ </ul>
1349
+
1350
+ <p class="tag_title">See Also:</p>
1351
+ <ul class="see">
1352
+
1353
+ <li><span class='object_link'><a href="#failure-instance_method" title="Servus::Base#failure (method)">#failure</a></span></li>
1354
+
1355
+ </ul>
1356
+
1357
+ </div><table class="source_code">
1358
+ <tr>
1359
+ <td>
1360
+ <pre class="lines">
1361
+
1362
+
1363
+ 140
1364
+ 141
1365
+ 142
1366
+ 143</pre>
1367
+ </td>
1368
+ <td>
1369
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 140</span>
1370
+
1371
+ <span class='kw'>def</span> <span class='id identifier rubyid_error!'>error!</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors/ServiceError.html" title="Servus::Support::Errors::ServiceError (class)">ServiceError</a></span></span><span class='rparen'>)</span>
1372
+ <span class='const'><span class='object_link'><a href="#Logger-constant" title="Servus::Base::Logger (constant)">Logger</a></span></span><span class='period'>.</span><span class='id identifier rubyid_log_exception'>log_exception</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span><span class='rparen'>)</span>
1373
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span>
1374
+ <span class='kw'>end</span></pre>
1375
+ </td>
1376
+ </tr>
1377
+ </table>
1378
+ </div>
1379
+
1380
+ <div class="method_details ">
1381
+ <h3 class="signature " id="failure-instance_method">
1382
+
1383
+ #<strong>failure</strong>(message = nil, type: Servus::Support::Errors::ServiceError) &#x21d2; <tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>
1384
+
1385
+
1386
+
1387
+
1388
+
1389
+ </h3><div class="docstring">
1390
+ <div class="discussion">
1391
+ <p>Creates a failure response with an error.</p>
1392
+
1393
+ <p>Use this method to return failure results from your service&#39;s call method.
1394
+ The failure is logged automatically and returns a response containing the error.</p>
1395
+
1396
+
1397
+ </div>
1398
+ </div>
1399
+ <div class="tags">
1400
+
1401
+ <div class="examples">
1402
+ <h4 class="tag_title">Examples:</h4>
1403
+
1404
+
1405
+ <h5 class="example_title"><div class='inline'><p>Using default error type with custom message</p>
1406
+ </div></h5>
1407
+
1408
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
1409
+ <span class='kw'>return</span> <span class='id identifier rubyid_failure'>failure</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>User not found</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_user_exists?'>user_exists?</span>
1410
+ <span class='comment'># ...
1411
+ </span><span class='kw'>end</span></code></pre>
1412
+
1413
+
1414
+ <h5 class="example_title"><div class='inline'><p>Using custom error type</p>
1415
+ </div></h5>
1416
+
1417
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
1418
+ <span class='kw'>return</span> <span class='id identifier rubyid_failure'>failure</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid payment</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors/BadRequestError.html" title="Servus::Support::Errors::BadRequestError (class)">BadRequestError</a></span></span><span class='rparen'>)</span>
1419
+ <span class='comment'># ...
1420
+ </span><span class='kw'>end</span></code></pre>
1421
+
1422
+
1423
+ <h5 class="example_title"><div class='inline'><p>Using error type&#39;s default message</p>
1424
+ </div></h5>
1425
+
1426
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
1427
+ <span class='kw'>return</span> <span class='id identifier rubyid_failure'>failure</span><span class='lparen'>(</span><span class='label'>type:</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors/NotFoundError.html" title="Servus::Support::Errors::NotFoundError (class)">NotFoundError</a></span></span><span class='rparen'>)</span>
1428
+ <span class='comment'># Uses &quot;Not found&quot; as the message
1429
+ </span><span class='kw'>end</span></code></pre>
1430
+
1431
+ </div>
1432
+ <p class="tag_title">Parameters:</p>
1433
+ <ul class="param">
1434
+
1435
+ <li>
1436
+
1437
+ <span class='name'>message</span>
1438
+
1439
+
1440
+ <span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
1441
+
1442
+
1443
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1444
+
1445
+
1446
+ &mdash;
1447
+ <div class='inline'><p>custom error message (uses error type&#39;s default if nil)</p>
1448
+ </div>
1449
+
1450
+ </li>
1451
+
1452
+ <li>
1453
+
1454
+ <span class='name'>type</span>
1455
+
1456
+
1457
+ <span class='type'>(<tt>Class</tt>)</span>
1458
+
1459
+
1460
+ <em class="default">(defaults to: <tt>Servus::Support::Errors::ServiceError</tt>)</em>
1461
+
1462
+
1463
+ &mdash;
1464
+ <div class='inline'><p>error class to instantiate (must inherit from ServiceError)</p>
1465
+ </div>
1466
+
1467
+ </li>
1468
+
1469
+ </ul>
1470
+
1471
+ <p class="tag_title">Returns:</p>
1472
+ <ul class="return">
1473
+
1474
+ <li>
1475
+
1476
+
1477
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
1478
+
1479
+
1480
+
1481
+ &mdash;
1482
+ <div class='inline'><p>response with success: false and the error</p>
1483
+ </div>
1484
+
1485
+ </li>
1486
+
1487
+ </ul>
1488
+
1489
+ <p class="tag_title">See Also:</p>
1490
+ <ul class="see">
1491
+
1492
+ <li><span class='object_link'><a href="#success-instance_method" title="Servus::Base#success (method)">#success</a></span></li>
1493
+
1494
+ <li><span class='object_link'><a href="#error!-instance_method" title="Servus::Base#error! (method)">#error!</a></span></li>
1495
+
1496
+ <li><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Support::Errors</a></span></li>
1497
+
1498
+ </ul>
1499
+
1500
+ </div><table class="source_code">
1501
+ <tr>
1502
+ <td>
1503
+ <pre class="lines">
1504
+
1505
+
1506
+ 112
1507
+ 113
1508
+ 114
1509
+ 115</pre>
1510
+ </td>
1511
+ <td>
1512
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 112</span>
1513
+
1514
+ <span class='kw'>def</span> <span class='id identifier rubyid_failure'>failure</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'><span class='object_link'><a href="../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors.html" title="Servus::Support::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Support/Errors/ServiceError.html" title="Servus::Support::Errors::ServiceError (class)">ServiceError</a></span></span><span class='rparen'>)</span>
1515
+ <span class='id identifier rubyid_error'>error</span> <span class='op'>=</span> <span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span>
1516
+ <span class='const'><span class='object_link'><a href="#Response-constant" title="Servus::Base::Response (constant)">Response</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>false</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span>
1517
+ <span class='kw'>end</span></pre>
1518
+ </td>
1519
+ </tr>
1520
+ </table>
1521
+ </div>
1522
+
1523
+ <div class="method_details ">
1524
+ <h3 class="signature " id="success-instance_method">
1525
+
1526
+ #<strong>success</strong>(data) &#x21d2; <tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>
1527
+
1528
+
1529
+
1530
+
1531
+
1532
+ </h3><div class="docstring">
1533
+ <div class="discussion">
1534
+ <p>Creates a successful response with the provided data.</p>
1535
+
1536
+ <p>Use this method to return successful results from your service&#39;s call method.
1537
+ The data will be validated against the RESULT_SCHEMA if one is defined.</p>
1538
+
1539
+
1540
+ </div>
1541
+ </div>
1542
+ <div class="tags">
1543
+
1544
+ <div class="examples">
1545
+ <h4 class="tag_title">Examples:</h4>
1546
+
1547
+
1548
+ <h5 class="example_title"><div class='inline'><p>Returning simple data</p>
1549
+ </div></h5>
1550
+
1551
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
1552
+ <span class='id identifier rubyid_success'>success</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>user_id:</span> <span class='int'>123</span><span class='comma'>,</span> <span class='label'>status:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>active</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
1553
+ <span class='kw'>end</span></code></pre>
1554
+
1555
+
1556
+ <h5 class="example_title"><div class='inline'><p>Returning nil for operations without data</p>
1557
+ </div></h5>
1558
+
1559
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
1560
+ <span class='id identifier rubyid_perform_action'>perform_action</span>
1561
+ <span class='id identifier rubyid_success'>success</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='rparen'>)</span>
1562
+ <span class='kw'>end</span></code></pre>
1563
+
1564
+ </div>
1565
+ <p class="tag_title">Parameters:</p>
1566
+ <ul class="param">
1567
+
1568
+ <li>
1569
+
1570
+ <span class='name'>data</span>
1571
+
1572
+
1573
+ <span class='type'>(<tt>Object</tt>)</span>
1574
+
1575
+
1576
+
1577
+ &mdash;
1578
+ <div class='inline'><p>the data to return in the response (typically a Hash)</p>
1579
+ </div>
1580
+
1581
+ </li>
1582
+
1583
+ </ul>
1584
+
1585
+ <p class="tag_title">Returns:</p>
1586
+ <ul class="return">
1587
+
1588
+ <li>
1589
+
1590
+
1591
+ <span class='type'>(<tt><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
1592
+
1593
+
1594
+
1595
+ &mdash;
1596
+ <div class='inline'><p>response with success: true and the provided data</p>
1597
+ </div>
1598
+
1599
+ </li>
1600
+
1601
+ </ul>
1602
+
1603
+ <p class="tag_title">See Also:</p>
1604
+ <ul class="see">
1605
+
1606
+ <li><span class='object_link'><a href="#failure-instance_method" title="Servus::Base#failure (method)">#failure</a></span></li>
1607
+
1608
+ <li><span class='object_link'><a href="Support/Response.html" title="Servus::Support::Response (class)">Support::Response</a></span></li>
1609
+
1610
+ </ul>
1611
+
1612
+ </div><table class="source_code">
1613
+ <tr>
1614
+ <td>
1615
+ <pre class="lines">
1616
+
1617
+
1618
+ 78
1619
+ 79
1620
+ 80</pre>
1621
+ </td>
1622
+ <td>
1623
+ <pre class="code"><span class="info file"># File 'lib/servus/base.rb', line 78</span>
1624
+
1625
+ <span class='kw'>def</span> <span class='id identifier rubyid_success'>success</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
1626
+ <span class='const'><span class='object_link'><a href="#Response-constant" title="Servus::Base::Response (constant)">Response</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1627
+ <span class='kw'>end</span></pre>
1628
+ </td>
1629
+ </tr>
1630
+ </table>
1631
+ </div>
1632
+
1633
+ </div>
1634
+
1635
+ </div>
1636
+
1637
+ <div id="footer">
1638
+ Generated on Fri Nov 21 00:33:24 2025 by
1639
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1640
+ 0.9.37 (ruby-3.4.4).
1641
+ </div>
1642
+
1643
+ </div>
1644
+ </body>
1645
+ </html>