Skip to content

[MODEL] Do not override existing methods #936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elasticsearch-model/lib/elasticsearch/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def self.search(query, options={})
end

DummyIncludingModel.__send__ :include, Elasticsearch::Model
DummyIncludingModelWithSearchMethodDefined.__send__ :include, Elasticsearch::Model

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah so there was a test for this (line 71) but it wasn't actually set up correctly. Nice!

end

after(:all) do
Expand Down