Skip to content

Commit 0f9f644

Browse files
committed
[API] Refactors Response object
1 parent a3b75e3 commit 0f9f644

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

elasticsearch-api/lib/elasticsearch/api/response.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ module API
2121
# the initializer and behaves like a Hash, except when status or headers are called upon it, in
2222
# which case it returns the original object's status and headers.
2323
class Response
24+
RESPONSE_METHODS = [:status, :body, :headers]
25+
2426
def initialize(response)
2527
@response = response
2628
end
2729

2830
def method_missing(method, *args, &block)
29-
if [:status, :body, :headers].include? method
31+
if RESPONSE_METHODS.include? method
3032
@response.send method.to_sym
3133
else
3234
@response.body.send(method.to_sym, *args, &block)
@@ -35,7 +37,7 @@ def method_missing(method, *args, &block)
3537

3638
def respond_to_missing?(method_name, include_private = false)
3739
@response.body.respond_to?(method_name, include_private) ||
38-
[:body, :headers, :status].include?(method_name)
40+
RESPONSE_METHODS.include?(method_name)
3941
end
4042

4143
def to_s

0 commit comments

Comments
 (0)