Class: CommandTower::Clients::NamespaceProxy
- Inherits:
-
Object
- Object
- CommandTower::Clients::NamespaceProxy
- Defined in:
- app/services/command_tower/clients/namespace_proxy.rb
Overview
Lightweight handle for a Zeitwerk namespace module under a provider. Internal resolution primitive — not the locked product invocation API.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#namespace_module ⇒ Object
readonly
Returns the value of attribute namespace_module.
Instance Method Summary collapse
-
#build_endpoint(name, client:) ⇒ Object
Memoize endpoint class resolution only; always return a fresh instance.
-
#initialize(client:, namespace_module:) ⇒ NamespaceProxy
constructor
A new instance of NamespaceProxy.
-
#resolve_endpoint!(name) ⇒ Object
Resolve and memoize an EndpointBase instance bound to this proxy's client.
- #resolve_endpoint_class!(name) ⇒ Object
Constructor Details
#initialize(client:, namespace_module:) ⇒ NamespaceProxy
Returns a new instance of NamespaceProxy.
10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/command_tower/clients/namespace_proxy.rb', line 10 def initialize(client:, namespace_module:) raise Errors::ConfigurationError, "client is required" if client.nil? raise Errors::ConfigurationError, "namespace_module is required" if namespace_module.nil? @client = client @namespace_module = namespace_module @endpoint_mutex = Mutex.new @endpoints = {} @endpoint_classes = {} end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'app/services/command_tower/clients/namespace_proxy.rb', line 8 def client @client end |
#namespace_module ⇒ Object (readonly)
Returns the value of attribute namespace_module.
8 9 10 |
# File 'app/services/command_tower/clients/namespace_proxy.rb', line 8 def namespace_module @namespace_module end |
Instance Method Details
#build_endpoint(name, client:) ⇒ Object
Memoize endpoint class resolution only; always return a fresh instance.
35 36 37 38 |
# File 'app/services/command_tower/clients/namespace_proxy.rb', line 35 def build_endpoint(name, client:) klass = resolve_endpoint_class!(name) build_endpoint_instance!(klass, client: client) end |
#resolve_endpoint!(name) ⇒ Object
Resolve and memoize an EndpointBase instance bound to this proxy's client. Prefer #build_endpoint for ScopedClient so user-bound instances are not shared.
23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/command_tower/clients/namespace_proxy.rb', line 23 def resolve_endpoint!(name) const_name = ConstResolution.normalize_name(name) @endpoint_mutex.synchronize do @endpoints[const_name] ||= build_endpoint_instance!( resolve_endpoint_class_locked!(const_name), client: client ) end end |
#resolve_endpoint_class!(name) ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/services/command_tower/clients/namespace_proxy.rb', line 40 def resolve_endpoint_class!(name) const_name = ConstResolution.normalize_name(name) @endpoint_mutex.synchronize do resolve_endpoint_class_locked!(const_name) end end |