Module: BWAPI::Configuration
- Included in:
- BWAPI
- Defined in:
- lib/bwapi/configuration.rb
Constant Summary collapse
- OPTION_KEYS =
[ :api_endpoint, :user_agent, :adapter, :username, :password, :grant_type, :access_token, :refresh_token, :expires_in, :client_id, :client_secret, :verify_ssl, :netrc, :netrc_file ].freeze
- DEFAULT_ADAPTER =
Faraday.default_adapter
- DEFAULT_API_ENDPOINT =
ENV['BWAPI_API_ENDPOINT'] || 'https://newapi.brandwatch.com/'
- DEFAULT_CLIENT_ID =
'brandwatch-api-client'- DEFAULT_USER_AGENT =
"BWAPI Ruby Gem #{BWAPI::VERSION}".freeze
- DEFAULT_NETRC_FILE =
File.join(ENV['HOME'], '.netrc')
Class Method Summary collapse
-
.extended(base) ⇒ Object
Extend hook.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Set configuration options using a block.
-
#options ⇒ Object
Convert option_keys to hash and return.
-
#reset ⇒ Object
Reset the configuration options.
Class Method Details
.extended(base) ⇒ Object
Extend hook
32 33 34 |
# File 'lib/bwapi/configuration.rb', line 32 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Set configuration options using a block
37 38 39 |
# File 'lib/bwapi/configuration.rb', line 37 def configure yield self end |
#options ⇒ Object
Convert option_keys to hash and return
42 43 44 |
# File 'lib/bwapi/configuration.rb', line 42 def OPTION_KEYS.inject({}){|o,k|o.merge!(k => send(k))} end |
#reset ⇒ Object
Reset the configuration options
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/bwapi/configuration.rb', line 47 def reset self.adapter = DEFAULT_ADAPTER self.user_agent = DEFAULT_USER_AGENT self.api_endpoint = DEFAULT_API_ENDPOINT self.username = nil self.password = nil self.grant_type = nil self.access_token = nil self.refresh_token = nil self.client_id = DEFAULT_CLIENT_ID self.client_secret = nil self.verify_ssl = true self.netrc = false self.netrc_file = DEFAULT_NETRC_FILE end |