From 88185092740b1b5fd5d277b588253765a66d3acb Mon Sep 17 00:00:00 2001 From: masarakki Date: Thu, 23 Apr 2020 22:09:38 +0900 Subject: [PATCH] fix-finding-query-methods `Queirs.const_defined? 'Foo'` find not only `Queries::Foo` but also `::Foo`, so if program has `Foo` class, this `method_missing` call `Foo.new` instead of call `foo` method. --- elasticsearch-dsl/lib/elasticsearch/dsl/search/query.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch-dsl/lib/elasticsearch/dsl/search/query.rb b/elasticsearch-dsl/lib/elasticsearch/dsl/search/query.rb index 9f896995e0..9ce9f20e01 100644 --- a/elasticsearch-dsl/lib/elasticsearch/dsl/search/query.rb +++ b/elasticsearch-dsl/lib/elasticsearch/dsl/search/query.rb @@ -38,8 +38,8 @@ def initialize(*args, &block) # def method_missing(name, *args, &block) klass = Utils.__camelize(name) - if Queries.const_defined? klass - @value = Queries.const_get(klass).new *args, &block + if Queries.const_defined? klass, false + @value = Queries.const_get(klass, false).new *args, &block elsif @block @block.binding.eval('self').send(name, *args, &block) else