Class: OmniService::Context
- Inherits:
-
Object
- Object
- OmniService::Context
- Extended by:
- Dry::Initializer
- Defined in:
- lib/omni_service/context.rb
Overview
Validates caller-provided context values against type specifications. Use for values passed at call time (current_user, request), not fetched entities. Raises Dry::Types::CoercionError on type mismatches (not validation errors). Only validates keys defined in schema; passes through undefined keys unchanged.
Instance Method Summary collapse
Instance Method Details
#call(*params, **context) ⇒ Object
21 22 23 24 |
# File 'lib/omni_service/context.rb', line 21 def call(*params, **context) validated = schema.to_h { |key, type| [key, type.call(context[key])] } OmniService::Result.build(self, params:, context: context.merge(validated)) end |
#signature ⇒ Object
26 27 28 |
# File 'lib/omni_service/context.rb', line 26 def signature [-1, true] end |