Class: OmniService::Optional
- Inherits:
-
Object
- Object
- OmniService::Optional
- Extended by:
- Dry::Initializer
- Includes:
- Strict
- Defined in:
- lib/omni_service/optional.rb
Overview
Swallows component failures, returning empty success instead. Useful for non-critical operations that shouldn’t block the pipeline.
On success: returns component result unchanged. On failure: returns Success({}) with empty context, discarding errors.
Instance Method Summary collapse
Methods included from Strict
Instance Method Details
#call(*params, **context) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/omni_service/optional.rb', line 30 def call(*params, **context) result = component_wrapper.call(*params, **context) if result.success? result else OmniService::Result.build(self, params: result.params, context: {}) end end |
#signature ⇒ Object
40 41 42 |
# File 'lib/omni_service/optional.rb', line 40 def signature @signature ||= [component_wrapper.signature.first, true] end |