Class: DataPlaneApi::Configuration
- Inherits:
-
Object
- Object
- DataPlaneApi::Configuration
- Defined in:
- lib/data_plane_api/configuration.rb
Overview
Stores configuration options for the HAProxy Data Plane API.
Instance Attribute Summary collapse
-
#basic_password ⇒ Object
Basic Auth password.
-
#basic_user ⇒ Object
Basic Auth username.
-
#global ⇒ Object
readonly
Whether this object is used as a global store of settings.
-
#logger ⇒ Object
: -> Logger?.
-
#mock ⇒ Object
: -> bool?.
-
#timeout ⇒ Object
: -> Integer?.
-
#url ⇒ Object
: -> (String | URI::Generic | nil).
Instance Method Summary collapse
-
#connection ⇒ Object
: -> Faraday::Connection.
-
#freeze ⇒ Object
: -> void.
-
#initialize(url: nil, global: false, mock: false, basic_user: nil, basic_password: nil, logger: nil, timeout: nil, parent: nil) ⇒ Configuration
constructor
: (String | URI::Generic | nil, bool, bool, String?, String?, Logger?, Integer?, Configuration?) -> void.
-
#mock? ⇒ Boolean
: -> bool.
-
#parent ⇒ Object
: -> Configuration?.
Constructor Details
#initialize(url: nil, global: false, mock: false, basic_user: nil, basic_password: nil, logger: nil, timeout: nil, parent: nil) ⇒ Configuration
: (String | URI::Generic | nil, bool, bool, String?, String?, Logger?, Integer?, Configuration?) -> void
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/data_plane_api/configuration.rb', line 36 def initialize( url: nil, global: false, mock: false, basic_user: nil, basic_password: nil, logger: nil, timeout: nil, parent: nil ) @global = global @mock = mock @url = url @basic_user = basic_user @basic_password = basic_password @logger = logger @timeout = timeout @parent = parent @connection = nil return unless global @logger ||= ::Logger.new($stdout) @timeout ||= 10 end |
Instance Attribute Details
#basic_password ⇒ Object
Basic Auth password. : -> String?
91 92 93 94 95 |
# File 'lib/data_plane_api/configuration.rb', line 91 def basic_password return @basic_password if @global || @basic_password parent&.basic_password end |
#basic_user ⇒ Object
Basic Auth username. : -> String?
83 84 85 86 87 |
# File 'lib/data_plane_api/configuration.rb', line 83 def basic_user return @basic_user if @global || @basic_user parent&.basic_user end |
#global ⇒ Object (readonly)
Whether this object is used as a global store of settings
: bool
30 31 32 |
# File 'lib/data_plane_api/configuration.rb', line 30 def global @global end |
#logger ⇒ Object
: -> Logger?
98 99 100 101 102 |
# File 'lib/data_plane_api/configuration.rb', line 98 def logger return @logger if @global || @logger parent&.logger end |
#mock ⇒ Object
: -> bool?
112 113 114 115 116 |
# File 'lib/data_plane_api/configuration.rb', line 112 def mock return @mock if @global || @mock parent&.mock end |
#timeout ⇒ Object
: -> Integer?
105 106 107 108 109 |
# File 'lib/data_plane_api/configuration.rb', line 105 def timeout return @timeout if @global || @timeout parent&.timeout end |
#url ⇒ Object
: -> (String | URI::Generic | nil)
75 76 77 78 79 |
# File 'lib/data_plane_api/configuration.rb', line 75 def url return @url if @global || @url parent&.url end |
Instance Method Details
#connection ⇒ Object
: -> Faraday::Connection
64 65 66 |
# File 'lib/data_plane_api/configuration.rb', line 64 def connection @connection || build_connection end |
#freeze ⇒ Object
: -> void
69 70 71 72 |
# File 'lib/data_plane_api/configuration.rb', line 69 def freeze @connection = build_connection super end |
#mock? ⇒ Boolean
: -> bool
119 120 121 |
# File 'lib/data_plane_api/configuration.rb', line 119 def mock? Boolean(mock) end |
#parent ⇒ Object
: -> Configuration?
124 125 126 127 128 |
# File 'lib/data_plane_api/configuration.rb', line 124 def parent return if @global @parent || CONFIG end |