Class: Torikago::RackEndpoint

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

Overview

A host-owned Rack endpoint that forwards requests to a registered module without exposing the module's Rails::Engine or controller constants in the main Box.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(module_name, registry: nil) ⇒ RackEndpoint

Returns a new instance of RackEndpoint.

Parameters:

  • module_name (Symbol, String)
  • registry: (Registry, nil) (defaults to: nil)


6
7
8
9
# File 'lib/torikago/rack_endpoint.rb', line 6

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

Instance Attribute Details

#module_nameSymbol (readonly)

Returns the value of attribute module_name.

Returns:

  • (Symbol)


17
18
19
# File 'lib/torikago/rack_endpoint.rb', line 17

def module_name
  @module_name
end

Instance Method Details

#call(env) ⇒ Object

Parameters:

  • env (Hash[String, untyped])

Returns:

  • (Object)


11
12
13
# File 'lib/torikago/rack_endpoint.rb', line 11

def call(env)
  registry.resolve(module_name).call(env)
end

#registryRegistry

Returns:



19
20
21
# File 'lib/torikago/rack_endpoint.rb', line 19

def registry
  @registry || Torikago.registry
end