From 0d87632fd371bda7e7085d511fef9c87e26f5f43 Mon Sep 17 00:00:00 2001 From: masarakki Date: Thu, 13 Jan 2022 14:48:51 +0000 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. --- lib/elasticsearch/dsl/search/query.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/elasticsearch/dsl/search/query.rb b/lib/elasticsearch/dsl/search/query.rb index 9f89699..9ce9f20 100644 --- a/lib/elasticsearch/dsl/search/query.rb +++ b/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