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.
-
#transformation_options ⇒ Object
Returns the value of attribute transformation_options.
-
#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
- #add_user_agent_segment(segment, version = nil) ⇒ Object
-
#initialize(app_id, api_key, hosts, client_name, opts = {}) {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #set_client_api_key(api_key) ⇒ Object
Constructor Details
#initialize(app_id, api_key, hosts, client_name, opts = {}) {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/algolia/configuration.rb', line 24 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] @connect_timeout = opts[:connect_timeout] @read_timeout = opts[:read_timeout] @write_timeout = opts[:write_timeout] @compression_type = opts[:compression_type] || "none" @requester = opts[:requester] @transformation_options = opts[:transformation_options] @user_agent = UserAgent.new.add(client_name, VERSION) if opts[:user_agent_segments] opts[:user_agent_segments].each do |segment| @user_agent.add(segment) end end @header_params = { "X-Algolia-Application-Id" => app_id, "X-Algolia-API-Key" => api_key, "Content-Type" => "application/json", "User-Agent" => @user_agent.value } @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.
22 23 24 |
# File 'lib/algolia/configuration.rb', line 22 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 |
#transformation_options ⇒ Object
Returns the value of attribute transformation_options.
5 6 7 |
# File 'lib/algolia/configuration.rb', line 5 def @transformation_options 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.
63 64 65 |
# File 'lib/algolia/configuration.rb', line 63 def self.default @@default ||= Configuration.new end |
Instance Method Details
#add_user_agent_segment(segment, version = nil) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/algolia/configuration.rb', line 67 def add_user_agent_segment(segment, version = nil) @user_agent.add(segment, version) @header_params["user-agent"] = @user_agent.value self end |
#set_client_api_key(api_key) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/algolia/configuration.rb', line 55 def set_client_api_key(api_key) @api_key = api_key @header_params["X-Algolia-API-Key"] = api_key self end |