Method: Justa::TokenManager.client_for

Defined in:
lib/justa/token_manager.rb

.client_for(key = Justa.default_client_key) ⇒ Justa::Client

Find a Client for a specific Key

Parameters:

  • key (Symbol) (defaults to: Justa.default_client_key)

    Client Key to be found in Authenticators Array ( Defaults to Justa.default_client_key)

Returns:

  • (Justa::Client)

    Client instance registed with the key passed



107
108
109
110
111
112
113
114
115
116
# File 'lib/justa/token_manager.rb', line 107

def self.client_for(key = Justa.default_client_key)
  k = Justa::Util.to_sym(key)
  instance unless @instance
  return nil unless @instance.authenticators.present?

  @instance.mutex.synchronize do
    auth = @instance.authenticators.find { |obj| obj.key == k }
    auth&.client
  end
end