Class: Waistband::QueryResult

Inherits:
Object
  • Object
show all
Defined in:
lib/waistband/query_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ QueryResult

Returns a new instance of QueryResult.



8
9
10
11
12
# File 'lib/waistband/query_result.rb', line 8

def initialize(row)
  @source = row['_source'].stringify_keys
  @_id    = row['_id']
  @score  = row['_score']
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



14
15
16
# File 'lib/waistband/query_result.rb', line 14

def method_missing(method_name, *args, &block)
  @source[method_name.to_s]
end

Instance Attribute Details

#_idObject (readonly)

Returns the value of attribute _id.



6
7
8
# File 'lib/waistband/query_result.rb', line 6

def _id
  @_id
end

#scoreObject (readonly)

Returns the value of attribute score.



6
7
8
# File 'lib/waistband/query_result.rb', line 6

def score
  @score
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/waistband/query_result.rb', line 6

def source
  @source
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/waistband/query_result.rb', line 18

def respond_to_missing?(method_name, include_private = false)
  return true if @source.has_key?(method_name.to_s)
  super
end