Skip to content

Commit 10ed5ca

Browse files
[MODEL] Do not override existing methods (elastic#936)
* [MODEL] Do not override existing methods * fix spec to cover this case * Fixes elastic#924
1 parent 4c44370 commit 10ed5ca

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

elasticsearch-model/lib/elasticsearch/model.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def self.included(base)
112112
# Delegate common methods to the `__elasticsearch__` ClassMethodsProxy, unless they are defined already
113113
class << self
114114
METHODS.each do |method|
115-
delegate method, to: :__elasticsearch__ unless self.respond_to?(method)
115+
delegate method, to: :__elasticsearch__ unless self.public_instance_methods.include?(method)
116116
end
117117
end
118118
end

elasticsearch-model/spec/elasticsearch/model/module_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def self.search(query, options={})
4848
end
4949

5050
DummyIncludingModel.__send__ :include, Elasticsearch::Model
51+
DummyIncludingModelWithSearchMethodDefined.__send__ :include, Elasticsearch::Model
5152
end
5253

5354
after(:all) do

0 commit comments

Comments
 (0)