Class: Algolia::BaseConfig
- Inherits:
-
Object
- Object
- Algolia::BaseConfig
- Defined in:
- lib/algolia/config/base_config.rb
Direct Known Subclasses
Analytics::Config, Insights::Config, Personalization::Config, Search::Config
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#compression_type ⇒ Object
Returns the value of attribute compression_type.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#symbolize_keys ⇒ Object
Returns the value of attribute symbolize_keys.
-
#use_latest_settings ⇒ Object
Returns the value of attribute use_latest_settings.
-
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BaseConfig
constructor
A new instance of BaseConfig.
- #set_extra_header(key, value) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ BaseConfig
Returns a new instance of BaseConfig.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/algolia/config/base_config.rb', line 17 def initialize(opts = {}) raise AlgoliaError, 'No Application ID provided, please set :application_id' unless opts.has_key?(:application_id) raise AlgoliaError, 'No API key provided, please set :api_key' unless opts.has_key?(:api_key) @app_id = opts[:application_id] @api_key = opts[:api_key] @headers = { Defaults::HEADER_API_KEY => @api_key, Defaults::HEADER_APP_ID => @app_id, 'Content-Type' => 'application/json; charset=utf-8', 'User-Agent' => UserAgent.value } @batch_size = opts[:batch_size] || Defaults::BATCH_SIZE @read_timeout = opts[:read_timeout] || Defaults::READ_TIMEOUT @write_timeout = opts[:write_timeout] || Defaults::WRITE_TIMEOUT @connect_timeout = opts[:connect_timeout] || Defaults::CONNECT_TIMEOUT @compression_type = opts[:compression_type] || Defaults::NONE_ENCODING @symbolize_keys = opts.has_key?(:symbolize_keys) ? opts[:symbolize_keys] : true end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def api_key @api_key end |
#app_id ⇒ Object
Returns the value of attribute app_id.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def app_id @app_id end |
#batch_size ⇒ Object
Returns the value of attribute batch_size.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def batch_size @batch_size end |
#compression_type ⇒ Object
Returns the value of attribute compression_type.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def compression_type @compression_type end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def connect_timeout @connect_timeout end |
#headers ⇒ Object
Returns the value of attribute headers.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def headers @headers end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def read_timeout @read_timeout end |
#symbolize_keys ⇒ Object
Returns the value of attribute symbolize_keys.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def symbolize_keys @symbolize_keys end |
#use_latest_settings ⇒ Object
Returns the value of attribute use_latest_settings.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def use_latest_settings @use_latest_settings end |
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
5 6 7 |
# File 'lib/algolia/config/base_config.rb', line 5 def write_timeout @write_timeout end |
Instance Method Details
#set_extra_header(key, value) ⇒ Object
39 40 41 |
# File 'lib/algolia/config/base_config.rb', line 39 def set_extra_header(key, value) @headers[key] = value end |