Class: LiveQA::Config
- Inherits:
-
Object
- Object
- LiveQA::Config
- Defined in:
- lib/liveqa/config.rb
Overview
LiveQA Config
Represent the LiveQA configuration for the API
Constant Summary collapse
- ASYNC_HANDLERS =
{ sidekiq: { class: 'LiveQA::AsyncHandlers::Sidekiq', require: 'liveqa/async_handlers/sidekiq' } }.freeze
- DEFAULT_OBFUSCATED_FIELDS =
%w[ password password_confirmation secret secret_token authenticity_token token api_key access_token credit_card_number cvv ccv ].freeze
Instance Attribute Summary collapse
-
#api_host ⇒ String
API host.
-
#api_key ⇒ String
API key.
-
#api_version ⇒ String
API version.
-
#async_handler ⇒ Null|Symbol|Proc
Asynchronous handler.
-
#async_options ⇒ Hash
Options for asynchronous handler.
-
#enabled ⇒ Boolean
Service is enable.
-
#http_secure ⇒ Boolean
Http secure.
-
#obfuscated_fields ⇒ Array[String]
Fields to obfuscate.
-
#proxy_url ⇒ String
Proxy url.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
Initialize and validate the configuration.
-
#valid! ⇒ Boolean
validate the configuration Raise when configuration are not valid.
Constructor Details
#initialize(options = {}) ⇒ Config
Initialize and validate the configuration
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/liveqa/config.rb', line 68 def initialize( = {}) self.api_key = [:api_key] self.api_host = [:api_host] || 'api.liveqa.io' self.api_version = [:api_version] || 'v1' self.proxy_url = [:proxy_url] self.http_secure = [:http_secure] || true self.enabled = [:enabled] || true self. = [:obfuscated_fields] || [] self.async_handler = [:async_handler] self. = [:async_options] || {} end |
Instance Attribute Details
#api_host ⇒ String
Returns API host.
35 36 37 |
# File 'lib/liveqa/config.rb', line 35 def api_host @api_host end |
#api_key ⇒ String
Returns API key.
31 32 33 |
# File 'lib/liveqa/config.rb', line 31 def api_key @api_key end |
#api_version ⇒ String
Returns API version.
39 40 41 |
# File 'lib/liveqa/config.rb', line 39 def api_version @api_version end |
#async_handler ⇒ Null|Symbol|Proc
Returns asynchronous handler.
59 60 61 |
# File 'lib/liveqa/config.rb', line 59 def async_handler @async_handler end |
#async_options ⇒ Hash
Returns options for asynchronous handler.
63 64 65 |
# File 'lib/liveqa/config.rb', line 63 def @async_options end |
#enabled ⇒ Boolean
Returns service is enable.
51 52 53 |
# File 'lib/liveqa/config.rb', line 51 def enabled @enabled end |
#http_secure ⇒ Boolean
Returns http secure.
47 48 49 |
# File 'lib/liveqa/config.rb', line 47 def http_secure @http_secure end |
#obfuscated_fields ⇒ Array[String]
Returns fields to obfuscate.
55 56 57 |
# File 'lib/liveqa/config.rb', line 55 def @obfuscated_fields end |
#proxy_url ⇒ String
Returns proxy url.
43 44 45 |
# File 'lib/liveqa/config.rb', line 43 def proxy_url @proxy_url end |
Instance Method Details
#valid! ⇒ Boolean
validate the configuration Raise when configuration are not valid
84 85 86 87 88 89 90 91 92 |
# File 'lib/liveqa/config.rb', line 84 def valid! format! %i[api_key api_host api_version].each do |field| validate_presence(field) end true end |