Class: Algolia::Configuration
- Inherits:
-
Object
- Object
- Algolia::Configuration
- Defined in:
- lib/algolia/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#client_side_validation ⇒ true, false
Set this to false to skip client side validation in the operation.
-
#compression_type ⇒ Object
Returns the value of attribute compression_type.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#header_params ⇒ Object
Returns the value of attribute header_params.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#requester ⇒ Object
Returns the value of attribute requester.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
Class Method Summary collapse
-
.default ⇒ Object
The default Configuration object.
Instance Method Summary collapse
-
#initialize(app_id, api_key, hosts, client_name, opts = {}) {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(app_id, api_key, hosts, client_name, opts = {}) {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/algolia/configuration.rb', line 23 def initialize(app_id, api_key, hosts, client_name, opts = {}) @hosts = hosts @app_id = app_id @api_key = api_key @client_side_validation = opts[:client_side_validation].nil? ? true : opts[:client_side_validation] @write_timeout = opts[:write_timeout] || 30_000 @read_timeout = opts[:read_timeout] || 5_000 @connect_timeout = opts[:connect_timeout] || 2_000 @compression_type = opts[:compression_type] || "none" @requester = opts[:requester] @user_agent = UserAgent.new.add(client_name, VERSION) @header_params = { "X-Algolia-Application-Id" => app_id, "X-Algolia-API-Key" => api_key, "Content-Type" => "application/json", "User-Agent" => @user_agent } @header_params.transform_keys!(&:downcase) yield(self) if block_given? end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/algolia/configuration.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/configuration.rb', line 5 def app_id @app_id end |
#client_side_validation ⇒ true, false
Set this to false to skip client side validation in the operation. Default to true.
21 22 23 |
# File 'lib/algolia/configuration.rb', line 21 def client_side_validation @client_side_validation end |
#compression_type ⇒ Object
Returns the value of attribute compression_type.
5 6 7 |
# File 'lib/algolia/configuration.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/configuration.rb', line 5 def connect_timeout @connect_timeout end |
#header_params ⇒ Object
Returns the value of attribute header_params.
5 6 7 |
# File 'lib/algolia/configuration.rb', line 5 def header_params @header_params end |
#hosts ⇒ Object
Returns the value of attribute hosts.
5 6 7 |
# File 'lib/algolia/configuration.rb', line 5 def hosts @hosts end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
5 6 7 |
# File 'lib/algolia/configuration.rb', line 5 def read_timeout @read_timeout end |
#requester ⇒ Object
Returns the value of attribute requester.
5 6 7 |
# File 'lib/algolia/configuration.rb', line 5 def requester @requester end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
5 6 7 |
# File 'lib/algolia/configuration.rb', line 5 def user_agent @user_agent end |
#write_timeout ⇒ Object
Returns the value of attribute write_timeout.
5 6 7 |
# File 'lib/algolia/configuration.rb', line 5 def write_timeout @write_timeout end |
Class Method Details
.default ⇒ Object
The default Configuration object.
48 49 50 |
# File 'lib/algolia/configuration.rb', line 48 def self.default @@default ||= Configuration.new end |