Class: CommandTower::Clients::ScopedClient::NamespaceHandle

Inherits:
Object
  • Object
show all
Defined in:
app/services/command_tower/clients/scoped_client.rb

Overview

Fresh endpoint instances bound to this scoped client (not memoized).

Instance Method Summary collapse

Constructor Details

#initialize(scoped_client:, namespace_proxy:) ⇒ NamespaceHandle

Returns a new instance of NamespaceHandle.



59
60
61
62
# File 'app/services/command_tower/clients/scoped_client.rb', line 59

def initialize(scoped_client:, namespace_proxy:)
  @scoped_client = scoped_client
  @namespace_proxy = namespace_proxy
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Raises:

  • (ArgumentError)


64
65
66
67
68
69
70
# File 'app/services/command_tower/clients/scoped_client.rb', line 64

def method_missing(name, *args, **attributes, &block)
  raise ArgumentError, "endpoint invocation does not take a block" if block
  raise ArgumentError, "endpoint invocation does not take positional args" if args.any?

  endpoint = @namespace_proxy.build_endpoint(name, client: @scoped_client)
  endpoint.call(**attributes)
end

Instance Method Details

#respond_to_missing?(_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'app/services/command_tower/clients/scoped_client.rb', line 72

def respond_to_missing?(_name, _include_private = false)
  true
end