File tree 1 file changed +11
-2
lines changed
elasticsearch-model/lib/elasticsearch/model/response
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,22 @@ def initialize(attributes)
10
10
# Delegate methods to `@result`
11
11
#
12
12
def method_missing ( method_name , *arguments )
13
- @result . respond_to? ( method_name . to_sym ) ? @result [ method_name . to_sym ] : super
13
+ case
14
+ when @result . respond_to? ( method_name . to_sym )
15
+ @result [ method_name . to_sym ]
16
+ when @result . _source && @result . _source . respond_to? ( method_name . to_sym )
17
+ @result . _source [ method_name . to_sym ]
18
+ else
19
+ super
20
+ end
14
21
end
15
22
16
23
# Respond to methods from `@result`
17
24
#
18
25
def respond_to? ( method_name , include_private = false )
19
- @result . has_key? ( method_name . to_sym ) || super
26
+ @result . has_key? ( method_name . to_sym ) || \
27
+ @result . _source && @result . _source . has_key? ( method_name . to_sym ) || \
28
+ super
20
29
end
21
30
22
31
# TODO: #to_s, #inspect, with support for Pry
You can’t perform that action at this time.
0 commit comments