Sha256: 37444c601844fe9bfe2e6e141692eea5e49504a29e72c67ef14622a8a9f6aa63

Contents?: true

Size: 521 Bytes

Versions: 7

Compression:

Stored size: 521 Bytes

Contents

require 'active_support/core_ext/hash/keys'

module Waistband
  class QueryResult

    attr_reader :source, :_id, :score

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

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

    def respond_to_missing?(method_name, include_private = false)
      return true if @source.keys.map(&:to_s).include?(method_name.to_s)
      super
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
waistband-0.2.4 lib/waistband/query_result.rb
waistband-0.2.3 lib/waistband/query_result.rb
waistband-0.2.2 lib/waistband/query_result.rb
waistband-0.2.1 lib/waistband/query_result.rb
waistband-0.2.0 lib/waistband/query_result.rb
waistband-0.1.1 lib/waistband/query_result.rb
waistband-0.0.15 lib/waistband/query_result.rb