Class: Torikago::Gateway

Inherits:
Object
  • Object
show all
Defined in:
lib/torikago/gateway.rb

Overview

Runtime entrypoint for all cross-module calls. It validates the package API manifest before dispatching into the target module container.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry:, configuration:, manifest_loader: nil) ⇒ Gateway

Returns a new instance of Gateway.



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

def initialize(registry:, configuration:, manifest_loader: nil)
  @registry = registry
  @configuration = configuration
  @manifest_loader = manifest_loader || method(:load_manifest)
  @manifests = {}
end

Class Method Details

.callObject



9
10
11
# File 'lib/torikago/gateway.rb', line 9

def call(...)
  Torikago.gateway.call(...)
end

Instance Method Details

#call(public_api_class_name, *args, **kwargs) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/torikago/gateway.rb', line 21

def call(public_api_class_name, *args, **kwargs)
  target_module = infer_target_module(public_api_class_name)
  caller_module = CurrentExecution.current_box

  # Validation happens before resolving the container so denied calls do not
  # accidentally boot or load the target module.
  validate_public_api!(target_module, public_api_class_name, caller_module)
  registry.resolve(target_module).call(public_api_class_name, *args, **kwargs)
end