diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index d50308d8d..04adaffc1 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -112,7 +112,7 @@ def self.included(base) # Delegate common methods to the `__elasticsearch__` ClassMethodsProxy, unless they are defined already class << self METHODS.each do |method| - delegate method, to: :__elasticsearch__ unless self.respond_to?(method) + delegate method, to: :__elasticsearch__ unless self.public_instance_methods.include?(method) end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb index 3f7d682d0..72c90f4c5 100644 --- a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb @@ -48,6 +48,7 @@ def self.search(query, options={}) end DummyIncludingModel.__send__ :include, Elasticsearch::Model + DummyIncludingModelWithSearchMethodDefined.__send__ :include, Elasticsearch::Model end after(:all) do