Class: SwaggerPetstoreOpenApi30::ApiKeyCredentials
- Inherits:
-
Object
- Object
- SwaggerPetstoreOpenApi30::ApiKeyCredentials
- Defined in:
- lib/swagger_petstore_open_api30/http/auth/api_key.rb
Overview
Data class for ApiKeyCredentials. Data class for ApiKeyCredentials.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Class Method Summary collapse
Instance Method Summary collapse
- #clone_with(api_key: nil) ⇒ Object
-
#initialize(api_key:) ⇒ ApiKeyCredentials
constructor
A new instance of ApiKeyCredentials.
Constructor Details
#initialize(api_key:) ⇒ ApiKeyCredentials
Returns a new instance of ApiKeyCredentials.
30 31 32 33 34 |
# File 'lib/swagger_petstore_open_api30/http/auth/api_key.rb', line 30 def initialize(api_key:) raise ArgumentError, 'api_key cannot be nil' if api_key.nil? @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
28 29 30 |
# File 'lib/swagger_petstore_open_api30/http/auth/api_key.rb', line 28 def api_key @api_key end |
Class Method Details
.from_env ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/swagger_petstore_open_api30/http/auth/api_key.rb', line 36 def self.from_env api_key = ENV['API_KEY_API_KEY'] all_nil = [ api_key ].all?(&:nil?) return nil if all_nil new(api_key: api_key) end |
Instance Method Details
#clone_with(api_key: nil) ⇒ Object
46 47 48 49 50 |
# File 'lib/swagger_petstore_open_api30/http/auth/api_key.rb', line 46 def clone_with(api_key: nil) api_key ||= self.api_key ApiKeyCredentials.new(api_key: api_key) end |