Module: CommandTower::Clients::Invocation

Included in:
CommandTower::Clients
Defined in:
app/services/command_tower/clients/invocation.rb

Overview

Product invocation boundary mixin. Host: module Clients; extend CommandTower::Clients::Invocation; end then Clients.mariana_tek(user:) / Clients.mariana_tek(access_token:). Provider resolution uses the extending module as the provider root (+self+).

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **scope, &block) ⇒ Object



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

def method_missing(name, *args, **scope, &block)
  return super if block || args.any?

  ScopedClient.new(provider: provider_for!(name), **scope)
rescue Errors::DiscoveryError
  super
end

Instance Method Details

#provider_for!(name) ⇒ Object



25
26
27
28
29
30
31
# File 'app/services/command_tower/clients/invocation.rb', line 25

def provider_for!(name)
  const_name = ConstResolution.normalize_name(name)

  providers_mutex.synchronize do
    providers[const_name] ||= ClientBase.resolve_provider!(name, root: self).new
  end
end

#reset_providers!Object

Test helper — clears memoized providers (and their transport pools).



34
35
36
37
38
# File 'app/services/command_tower/clients/invocation.rb', line 34

def reset_providers!
  providers_mutex.synchronize do
    providers.clear
  end
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'app/services/command_tower/clients/invocation.rb', line 18

def respond_to_missing?(name, include_private = false)
  ClientBase.resolve_provider!(name, root: self)
  true
rescue Errors::DiscoveryError
  super
end

#seed_provider!(name, provider) ⇒ Object

Test helper — seed a provider instance under a normalized name.



41
42
43
44
45
46
# File 'app/services/command_tower/clients/invocation.rb', line 41

def seed_provider!(name, provider)
  const_name = ConstResolution.normalize_name(name)
  providers_mutex.synchronize do
    providers[const_name] = provider
  end
end