Class: Mackerel::Configuration::Config
- Inherits:
-
Object
- Object
- Mackerel::Configuration::Config
- Defined in:
- lib/mackerel/configuration.rb
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#http_accept ⇒ Object
Returns the value of attribute http_accept.
-
#params_encoder ⇒ Object
Returns the value of attribute params_encoder.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#request ⇒ Object
Returns the value of attribute request.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #http_request_headers ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
14 15 16 17 18 19 20 21 |
# File 'lib/mackerel/configuration.rb', line 14 def initialize @api_endpoint = 'https://mackerel.io/api/v0' @api_key = ENV['MACKEREL_APIKEY'] @http_accept = 'application/json' @user_agent = "Mackerel.rb Ruby Gem #{Mackerel::VERSION}" @params_encoder = Faraday::FlatParamsEncoder @proxy = nil end |
Instance Attribute Details
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
12 13 14 |
# File 'lib/mackerel/configuration.rb', line 12 def api_endpoint @api_endpoint end |
#api_key ⇒ Object
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/mackerel/configuration.rb', line 12 def api_key @api_key end |
#http_accept ⇒ Object
Returns the value of attribute http_accept.
12 13 14 |
# File 'lib/mackerel/configuration.rb', line 12 def http_accept @http_accept end |
#params_encoder ⇒ Object
Returns the value of attribute params_encoder.
12 13 14 |
# File 'lib/mackerel/configuration.rb', line 12 def params_encoder @params_encoder end |
#proxy ⇒ Object
Returns the value of attribute proxy.
12 13 14 |
# File 'lib/mackerel/configuration.rb', line 12 def proxy @proxy end |
#request ⇒ Object
Returns the value of attribute request.
12 13 14 |
# File 'lib/mackerel/configuration.rb', line 12 def request @request end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
12 13 14 |
# File 'lib/mackerel/configuration.rb', line 12 def user_agent @user_agent end |
Instance Method Details
#http_request_headers ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/mackerel/configuration.rb', line 29 def http_request_headers headers = { 'Accept' => http_accept, 'User-Agent' => user_agent, 'X-Api-Key' => api_key, } headers.select {|_, v| !!v} end |