Sha256: 2db6b59ab136c32ca9ffb7f1047d6796932310eb5111b8ca1c0b8277cec58afb
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
module Trailblazer::V2_1::Rails module Controller def run_v21(operation, *dependencies) result = if Rails.application.config.trailblazer.enable_tracing _run_operation_v21(operation, :trace, *dependencies).tap { |r| _operation_trace(r) } else _run_operation_v21(operation, :call, *dependencies) end _assign_trb_ivars(result) yield(result) if result.success? && block_given? @_result = result end alias run run_v21 unless method_defined?(:run) private # Override to tweak params. Not recommended. # Use a deserializer instead. def _run_params(params) params end # This is where we can inject Dry.RB containers and the like via dependencies. def _run_runtime_options(ctx = {}, *dependencies) [_run_options(ctx), *dependencies] end # Override this to inject dependencies such as "current_user" # into the runtime options. def _run_options(ctx) ctx end def _run_operation_v21(operation, call_method, *dependencies) operation.send( call_method, {params: _run_params(self.params)}.merge(*_run_runtime_options(*dependencies)) # rubocop:disable Style/RedundantSelf ) end def _operation_trace(result) puts result.wtf? end def _assign_trb_ivars(result) @model = result[:model] @form = _wrap_with_trb_form(result["contract.default"], @model.class) end def _wrap_with_trb_form(form, model) Trailblazer::V2_1::Rails::Form.new(form, model) end module Result def result @_result end end include Result end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trailblazer-future-2.1.0.rc1 | lib/trailblazer/v2_1/rails/controller.rb |