Class: Algolia::Transport::RequestOptions
- Inherits:
-
Object
- Object
- Algolia::Transport::RequestOptions
- Defined in:
- lib/algolia/transport/request_options.rb
Instance Attribute Summary collapse
-
#compression_type ⇒ Object
Returns the value of attribute compression_type.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#data ⇒ Object
Returns the value of attribute data.
-
#header_params ⇒ Object
Returns the value of attribute header_params.
-
#query_params ⇒ Object
Returns the value of attribute query_params.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#add_compression_type(opts = {}) ⇒ Object
Add or update compression_type.
-
#add_connect_timeout(opts = {}) ⇒ Object
Add or update connect timeout.
-
#add_header_params(opts = {}) ⇒ Object
Add or update header_params.
-
#add_query_params(opts = {}) ⇒ Object
Add or update query parameters.
-
#add_timeout(opts = {}) ⇒ Object
Add or update timeout.
-
#create(opts = {}) ⇒ Object
Create and format headers and query params from request options.
-
#initialize(config) ⇒ RequestOptions
constructor
A new instance of RequestOptions.
Constructor Details
#initialize(config) ⇒ RequestOptions
Returns a new instance of RequestOptions.
8 9 10 11 12 13 14 |
# File 'lib/algolia/transport/request_options.rb', line 8 def initialize(config) @header_params = {} @query_params = {} @timeout = nil @connect_timeout = nil @compression_type = config.compression_type end |
Instance Attribute Details
#compression_type ⇒ Object
Returns the value of attribute compression_type.
4 5 6 |
# File 'lib/algolia/transport/request_options.rb', line 4 def compression_type @compression_type end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
4 5 6 |
# File 'lib/algolia/transport/request_options.rb', line 4 def connect_timeout @connect_timeout end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/algolia/transport/request_options.rb', line 4 def data @data end |
#header_params ⇒ Object
Returns the value of attribute header_params.
4 5 6 |
# File 'lib/algolia/transport/request_options.rb', line 4 def header_params @header_params end |
#query_params ⇒ Object
Returns the value of attribute query_params.
4 5 6 |
# File 'lib/algolia/transport/request_options.rb', line 4 def query_params @query_params end |
#timeout ⇒ Object
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/algolia/transport/request_options.rb', line 4 def timeout @timeout end |
Instance Method Details
#add_compression_type(opts = {}) ⇒ Object
Add or update compression_type
78 79 80 81 |
# File 'lib/algolia/transport/request_options.rb', line 78 def add_compression_type(opts = {}) @compression_type = opts[:compression_type] || @compression_type opts.delete(:compression_type) end |
#add_connect_timeout(opts = {}) ⇒ Object
Add or update connect timeout
69 70 71 72 |
# File 'lib/algolia/transport/request_options.rb', line 69 def add_connect_timeout(opts = {}) @connect_timeout = opts[:connect_timeout] || @connect_timeout opts.delete(:connect_timeout) end |
#add_header_params(opts = {}) ⇒ Object
Add or update header_params
32 33 34 35 36 37 38 39 40 |
# File 'lib/algolia/transport/request_options.rb', line 32 def add_header_params(opts = {}) return if opts[:header_params].nil? opts[:header_params].each do |opt, value| @header_params[opt.to_s] = value end opts.delete(:header_params) end |
#add_query_params(opts = {}) ⇒ Object
Add or update query parameters
46 47 48 49 50 51 52 53 54 |
# File 'lib/algolia/transport/request_options.rb', line 46 def add_query_params(opts = {}) return if opts[:query_params].nil? opts[:query_params].each do |opt, value| @query_params[opt.to_sym] = value end opts.delete(:query_params) end |
#add_timeout(opts = {}) ⇒ Object
Add or update timeout
60 61 62 63 |
# File 'lib/algolia/transport/request_options.rb', line 60 def add_timeout(opts = {}) @timeout = opts[:timeout] || @timeout opts.delete(:timeout) end |
#create(opts = {}) ⇒ Object
Create and format headers and query params from request options
20 21 22 23 24 25 26 |
# File 'lib/algolia/transport/request_options.rb', line 20 def create(opts = {}) add_header_params(opts) add_query_params(opts) add_timeout(opts) add_connect_timeout(opts) add_compression_type(opts) end |