Class: Textus::Surface::MCP::Projector

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/surface/mcp/projector.rb

Instance Method Summary collapse

Constructor Details

#initialize(view_key: :default) ⇒ Projector

Returns a new instance of Projector.



5
6
7
# File 'lib/textus/surface/mcp/projector.rb', line 5

def initialize(view_key: :default)
  @view_key = view_key
end

Instance Method Details

#dispatch(verb_name, inputs:, store:) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
# File 'lib/textus/surface/mcp/projector.rb', line 9

def dispatch(verb_name, inputs:, store:)
  spec = VerbRegistry.for(verb_name.to_sym)
  raise Textus::UsageError.new("unknown verb: #{verb_name}") unless spec

  bound = Textus::Dispatch::Binder.inputs_from_wire(spec, inputs)
  result = store.public_send(verb_name.to_sym, **bound)
  spec.view(@view_key).call(result, bound)
end