Class: Esearch::Request
- Inherits:
-
Object
- Object
- Esearch::Request
- Includes:
- Adamantium::Flat
- Defined in:
- lib/esearch/request.rb
Overview
Request used to interface elasticsearch
Constant Summary collapse
- EMPTY_HASH =
{}.freeze
Instance Attribute Summary collapse
-
#body ⇒ Hash
readonly
private
Return body.
-
#params ⇒ Hash
readonly
private
Return params.
-
#path ⇒ String
readonly
private
Return path.
-
#verb ⇒ Symbol
readonly
private
Return http verb.
Instance Method Summary collapse
-
#initialize(verb, path, body = EMPTY_HASH, params = EMPTY_HASH) ⇒ undefined
constructor
private
Initialize object.
-
#log_string ⇒ String
private
Return log string.
-
#run(connection) ⇒ Faraday::Response
private
Run request on connection.
Constructor Details
#initialize(verb, path, body = EMPTY_HASH, params = EMPTY_HASH) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize object
54 55 56 |
# File 'lib/esearch/request.rb', line 54 def initialize(verb, path, body = EMPTY_HASH, params = EMPTY_HASH) @verb, @path, @body, @params = verb, path.to_s, body, params end |
Instance Attribute Details
#body ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return body
33 34 35 |
# File 'lib/esearch/request.rb', line 33 def body @body end |
#params ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return params
41 42 43 |
# File 'lib/esearch/request.rb', line 41 def params @params end |
#path ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return path
25 26 27 |
# File 'lib/esearch/request.rb', line 25 def path @path end |
#verb ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return http verb
17 18 19 |
# File 'lib/esearch/request.rb', line 17 def verb @verb end |
Instance Method Details
#log_string ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return log string
64 65 66 |
# File 'lib/esearch/request.rb', line 64 def log_string "#{verb.upcase} #{path} : #{params} : #{body}" end |
#run(connection) ⇒ Faraday::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run request on connection
77 78 79 80 81 82 83 |
# File 'lib/esearch/request.rb', line 77 def run(connection) connection.public_send(verb, path) do |request| request.params = params request.headers[:content_type] = Command::JSON_CONTENT_TYPE request.body = MultiJson.dump(body) end end |