Class: PetstoreApiClient::Authentication::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/petstore_api_client/authentication/base.rb

Overview

Base class for authentication strategies Implements Strategy Pattern - allows different authentication methods to be swapped without changing client code

This follows the same pattern as battle-tested gems like:

  • Octokit (GitHub API client)

  • Slack-ruby-client

  • Stripe Ruby library

Direct Known Subclasses

ApiKey, Composite, None, OAuth2

Instance Method Summary collapse

Instance Method Details

#apply(env) ⇒ void

This method returns an undefined value.

Apply authentication to a Faraday request environment

Parameters:

  • env (Faraday::Env)

    The request environment

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/petstore_api_client/authentication/base.rb', line 18

def apply(env)
  raise NotImplementedError, "#{self.class.name} must implement #apply"
end

#configured?Boolean

Check if this authentication strategy is configured Used to determine if auth should be applied

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/petstore_api_client/authentication/base.rb', line 26

def configured?
  raise NotImplementedError, "#{self.class.name} must implement #configured?"
end

#typeString

Human-readable description of authentication type Useful for logging and debugging

Returns:

  • (String)


34
35
36
# File 'lib/petstore_api_client/authentication/base.rb', line 34

def type
  self.class.name.split("::").last
end