Commit b7f2e279fa4b2c5110e12360ea8c7eb6fef62b47
1 parent
832fbe51
Exists in
master
and in
21 other branches
use hash interface
Showing
1 changed file
with
2 additions
and
13 deletions
Show diff stats
lib/searchkick/middleware.rb
... | ... | @@ -3,21 +3,10 @@ require "faraday/middleware" |
3 | 3 | module Searchkick |
4 | 4 | class Middleware < Faraday::Middleware |
5 | 5 | def call(env) |
6 | - is_search = env_value(env, :url).path.to_s.end_with?("/_search") | |
7 | - | |
8 | - if env_value(env, :method) == :get && is_search | |
9 | - r = env_value(env, :request) | |
10 | - if r.is_a?(Hash) | |
11 | - r[:timeout] = Searchkick.search_timeout | |
12 | - else | |
13 | - r.timeout = Searchkick.search_timeout | |
14 | - end | |
6 | + if env[:method] == :get && env[:url][:path].to_s.end_with?("/_search") | |
7 | + env[:request][:timeout] = Searchkick.search_timeout | |
15 | 8 | end |
16 | 9 | @app.call(env) |
17 | 10 | end |
18 | - | |
19 | - def env_value(env, key) | |
20 | - env.is_a?(Hash) ? env[key] : env.send(key) | |
21 | - end | |
22 | 11 | end |
23 | 12 | end | ... | ... |