class RatatuiRuby::Tea::Command::Mapped
Wraps another commandās result with a transformation.
Fractal Architecture requires composition. Child fragments produce commands with their own tags. Parent fragments need those results routed back with a parent prefix. Without transformation, update functions become monolithic āGod Reducersā that know about every childās internals.
This command wraps an inner command and transforms its result message. The parent fragment delegates to the child, then intercepts the result and adds its routing prefix. Clean separation. No coupling.
Use it to compose child fragments that return their own commands.
Public Instance Methods
Source
# File lib/ratatui_ruby/tea/command.rb, line 375 def call(out, token) inner_channel = Concurrent::Promises::Channel.new inner_outlet = Outlet.new(inner_channel, lifecycle: out.live) # Dispatch inner command if inner_command.respond_to?(:call) inner_command.call(inner_outlet, token) else raise ArgumentError, "Inner command must respond to #call" end # Transform result and send inner_message = inner_channel.pop transformed = mapper.call(inner_message) out.put(*transformed) end
Executes the inner command, waits for result, and transforms it.
Source
# File lib/ratatui_ruby/tea/command.rb, line 369 def tea_cancellation_grace_period inner_command.respond_to?(:tea_cancellation_grace_period) ? inner_command.tea_cancellation_grace_period : 0.1 end
Grace period delegates to inner command.