Class: Authentik::ApiProxy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/authentik/api_proxy.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

ApiProxy wraps an auto-generated OpenAPI API class and forwards method calls to it, stripping the redundant API group prefix from method names.

For example, when accessed via client.core, the prefix “core_” is stripped, so client.core.applications_list calls CoreApi#core_applications_list.

Instance Method Summary collapse

Constructor Details

#initialize(api_instance, prefix) ⇒ ApiProxy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ApiProxy.

Parameters:

  • api_instance (Object)

    The underlying OpenAPI API class instance

  • prefix (String)

    The method prefix to strip (e.g., “core_”)



15
16
17
18
# File 'lib/authentik/api_proxy.rb', line 15

def initialize(api_instance, prefix)
  @api = api_instance
  @prefix = prefix
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Forwards method calls to the underlying API instance. First tries with the prefix prepended (unless already prefixed), then without.



22
23
24
25
26
27
28
29
30
31
# File 'lib/authentik/api_proxy.rb', line 22

def method_missing(name, *args, **kwargs, &block)
  prefixed = name.to_s.start_with?(@prefix) ? name : :"#{@prefix}#{name}"
  if @api.respond_to?(prefixed)
    @api.send(prefixed, *args, **kwargs, &block)
  elsif @api.respond_to?(name)
    @api.send(name, *args, **kwargs, &block)
  else
    super
  end
end

Instance Method Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


33
34
35
36
37
38
# File 'lib/authentik/api_proxy.rb', line 33

def respond_to_missing?(name, include_private = false)
  prefixed = name.to_s.start_with?(@prefix) ? name : :"#{@prefix}#{name}"
  @api.respond_to?(prefixed) ||
    @api.respond_to?(name) ||
    super
end