Class: Torikago::ControllerEndpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/torikago/controller_endpoint.rb,
sig/torikago.rbs

Overview

A host-owned Rack-compatible route endpoint that dispatches directly to a controller class loaded inside a registered module runtime. It is not Rack middleware. The host router never resolves the controller constant, so Rails::Engine is not required for isolation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(module_name, controller_name, action_name, registry: nil) ⇒ ControllerEndpoint

Returns a new instance of ControllerEndpoint.



7
8
9
10
11
12
# File 'lib/torikago/controller_endpoint.rb', line 7

def initialize(module_name, controller_name, action_name, registry: nil)
  @module_name = module_name.to_sym
  @controller_name = controller_name.to_s
  @action_name = action_name.to_sym
  @registry = registry
end

Instance Attribute Details

#action_nameSymbol (readonly)

Returns the value of attribute action_name.

Returns:

  • (Symbol)


24
25
26
# File 'lib/torikago/controller_endpoint.rb', line 24

def action_name
  @action_name
end

#controller_nameString (readonly)

Returns the value of attribute controller_name.

Returns:

  • (String)


24
25
26
# File 'lib/torikago/controller_endpoint.rb', line 24

def controller_name
  @controller_name
end

#module_nameSymbol (readonly)

Returns the value of attribute module_name.

Returns:

  • (Symbol)


24
25
26
# File 'lib/torikago/controller_endpoint.rb', line 24

def module_name
  @module_name
end

Instance Method Details

#call(env) ⇒ Object

Parameters:

  • env (Hash[String, untyped])

Returns:

  • (Object)


14
15
16
17
18
19
20
# File 'lib/torikago/controller_endpoint.rb', line 14

def call(env)
  registry.resolve(module_name).dispatch_controller(
    env,
    controller_name: controller_name,
    action_name: action_name
  )
end

#registryRegistry

Returns:



26
27
28
# File 'lib/torikago/controller_endpoint.rb', line 26

def registry
  @registry || Torikago.registry
end