Module: CommandTower::Clients::ConstResolution

Defined in:
app/services/command_tower/clients/const_resolution.rb

Overview

Internal constant helpers for provider/namespace/endpoint resolution. Not a public product API — used by ClientBase / NamespaceProxy and tests.

Class Method Summary collapse

Class Method Details

.const_get!(parent, name, expected:) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/command_tower/clients/const_resolution.rb', line 19

def const_get!(parent, name, expected:)
  const_name = normalize_name(name)
  path = "#{parent.name}::#{const_name}"

  begin
    parent.const_get(const_name, false)
  rescue NameError
    raise Errors::DiscoveryError,
          "missing #{expected}: expected #{path}"
  end
end

.normalize_name(name) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/services/command_tower/clients/const_resolution.rb', line 10

def normalize_name(name)
  raw = name.to_s.strip
  if raw.empty?
    raise Errors::DiscoveryError, "discovery name must be present"
  end

  raw.camelize
end