Class: Esearch::Request
- Inherits:
-
Object
- Object
- Esearch::Request
- Includes:
- Adamantium
- 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
52 53 54 |
# File 'lib/esearch/request.rb', line 52 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
31 32 33 |
# File 'lib/esearch/request.rb', line 31 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
39 40 41 |
# File 'lib/esearch/request.rb', line 39 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
23 24 25 |
# File 'lib/esearch/request.rb', line 23 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
15 16 17 |
# File 'lib/esearch/request.rb', line 15 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
62 63 64 |
# File 'lib/esearch/request.rb', line 62 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
75 76 77 78 79 80 81 |
# File 'lib/esearch/request.rb', line 75 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 |