trailblazer-operation
trailblazer-operation copied to clipboard
Class Dependencies (possible implementation change)
Class Dependencies
- Class dependencies allow setting (temporary?) ctx variables for an operation.
- Currently, those variables stay in the result ctx and hence bleed through to the outer operation when nested. Maybe an
expose: true
could configure this?
class Index < Trailblazer::Operation
extend ClassDependencies
self["model.class"] = Module
step ->(ctx, **) { ctx["a"] = ctx["model.class"] }
end
Implementation
- Currently, in
#public_call
and#call_with_circuit_interface
we create a newContext
where those variables are set. - Ideally, we should use
:inject
and/or:input
instead in the outer operation and set the inner class variables with an injection. This would also reduce run-time logic. E.g. theSubprocess()
macro could take care of this. - For the topmost operation, the endpoint could be doing this, instead of clumsily hacking this feature.