Class: Waistband::Result
- Inherits:
-
Object
- Object
- Waistband::Result
- Defined in:
- lib/waistband/result.rb
Instance Method Summary collapse
-
#initialize(result_hash) ⇒ Result
constructor
A new instance of Result.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(result_hash) ⇒ Result
Returns a new instance of Result.
4 5 6 |
# File 'lib/waistband/result.rb', line 4 def initialize(result_hash) @result_hash = result_hash end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
8 9 10 11 12 |
# File 'lib/waistband/result.rb', line 8 def method_missing(method_name, *args, &block) return @result_hash[method_name.to_s] if @result_hash.keys.include?(method_name.to_s) return @result_hash['_source'][method_name.to_s] if @result_hash['_source'] && @result_hash['_source'].keys.include?(method_name.to_s) nil end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/waistband/result.rb', line 14 def respond_to_missing?(method_name, include_private = false) return true if @result_hash.keys.include?(method_name.to_s) return true if @result_hash['_source'] && @result_hash['_source'].keys.include?(method_name.to_s) super end |