Skip to content

Commit dd26f59

Browse files
committed
[MODEL] Added, that HashWrapper, a sub-class of Hashie::Mash is used
To prevent Hashie warnings, use the class introduced in 5732fa3 for wrapping Hashes, instead of Hashie::Mash directly. Closes elastic#666
1 parent a102c92 commit dd26f59

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

elasticsearch-model/lib/elasticsearch/model.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
require 'elasticsearch'
2-
3-
require 'hashie'
1+
require 'hashie/mash'
42

53
require 'active_support/core_ext/module/delegation'
64

5+
require 'elasticsearch'
6+
77
require 'elasticsearch/model/version'
88

9+
require 'elasticsearch/model/hash_wrapper'
910
require 'elasticsearch/model/client'
1011

1112
require 'elasticsearch/model/multimodel'

elasticsearch-model/lib/elasticsearch/model/response.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def initialize(klass, search, options={})
2828
#
2929
def response
3030
@response ||= begin
31-
Hashie::Mash.new(search.execute!)
31+
HashWrapper.new(search.execute!)
3232
end
3333
end
3434

@@ -63,7 +63,7 @@ def timed_out
6363
# Returns the statistics on shards
6464
#
6565
def shards
66-
Hashie::Mash.new(response['_shards'])
66+
HashWrapper.new(response['_shards'])
6767
end
6868

6969
# Returns a Hashie::Mash of the aggregations

elasticsearch-model/lib/elasticsearch/model/response/result.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Result
1414
# @param attributes [Hash] A Hash with document properties
1515
#
1616
def initialize(attributes={})
17-
@result = Hashie::Mash.new(attributes)
17+
@result = HashWrapper.new(attributes)
1818
end
1919

2020
# Return document `_id` as `id`

elasticsearch-model/test/unit/response_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.document_type; 'bar'; end
2727
assert_equal 'OK', response.shards.one
2828
end
2929

30-
should "wrap the raw Hash response in Hashie::Mash" do
30+
should "wrap the raw Hash response in a HashWrapper" do
3131
@search = Elasticsearch::Model::Searching::SearchRequest.new OriginClass, '*'
3232
@search.stubs(:execute!).returns({'hits' => { 'hits' => [] }, 'aggregations' => { 'dates' => 'FOO' }})
3333

0 commit comments

Comments
 (0)