Sha256: 84e49c32452b140f25717d6ef897ecf6ff9c8a2db10bf509876f9f78e0597769

Contents?: true

Size: 503 Bytes

Versions: 17

Compression:

Stored size: 503 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.has_key?(method_name.to_s)
      super
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
waistband-0.8.5 lib/waistband/query_result.rb
waistband-0.8.4 lib/waistband/query_result.rb
waistband-0.8.3 lib/waistband/query_result.rb
waistband-0.8.2 lib/waistband/query_result.rb
waistband-0.8.1 lib/waistband/query_result.rb
waistband-0.8.0 lib/waistband/query_result.rb
waistband-0.7.4 lib/waistband/query_result.rb
waistband-0.7.3 lib/waistband/query_result.rb
waistband-0.7.1 lib/waistband/query_result.rb
waistband-0.7.0 lib/waistband/query_result.rb
waistband-0.4.2 lib/waistband/query_result.rb
waistband-0.4.1 lib/waistband/query_result.rb
waistband-0.4.0 lib/waistband/query_result.rb
waistband-0.3.2 lib/waistband/query_result.rb
waistband-0.3.1 lib/waistband/query_result.rb
waistband-0.3.0 lib/waistband/query_result.rb
waistband-0.2.5 lib/waistband/query_result.rb