Commit 44493aceb52cd37d18ad130178a8abfc66e7df89

Authored by Mikel Kew
Committed by Andrew Kane
1 parent e04e38ab

Adding a HashWrapper for results to prevent Hashie log warnings (#859)

lib/searchkick.rb
... ... @@ -6,6 +6,7 @@ require "searchkick/index_options"
6 6 require "searchkick/index"
7 7 require "searchkick/indexer"
8 8 require "searchkick/reindex_queue"
  9 +require "searchkick/hash_wrapper"
9 10 require "searchkick/results"
10 11 require "searchkick/query"
11 12 require "searchkick/multi_search"
... ...
lib/searchkick/hash_wrapper.rb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +module Searchkick
  2 + # Subclass of `Hashie::Mash` to wrap Hash-like structures
  3 + # (responses from Elasticsearch)
  4 + #
  5 + # The primary goal of the subclass is to disable the
  6 + # warning being printed by Hashie for re-defined
  7 + # methods, such as `sort`.
  8 + #
  9 + class HashWrapper < ::Hashie::Mash
  10 + disable_warnings if respond_to?(:disable_warnings)
  11 + end
  12 +end
... ...
lib/searchkick/results.rb
... ... @@ -68,7 +68,7 @@ module Searchkick
68 68 end
69 69  
70 70 result["id"] ||= result["_id"] # needed for legacy reasons
71   - Hashie::Mash.new(result)
  71 + HashWrapper.new(result)
72 72 end
73 73 end
74 74 end
... ...