Commit e6e032f952b864a21dc08c6c0b9323eaaea9ab1a
1 parent
0d3b9389
Exists in
master
and in
2 other branches
Fixed instance method overriding with concerns - fixes #1547
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/model.rb
... | ... | @@ -22,16 +22,18 @@ module Searchkick |
22 | 22 | raise ArgumentError, "Invalid value for callbacks" |
23 | 23 | end |
24 | 24 | |
25 | + base = self | |
26 | + | |
25 | 27 | mod = Module.new |
26 | 28 | include(mod) |
27 | 29 | mod.module_eval do |
28 | 30 | def reindex(method_name = nil, mode: nil, refresh: false) |
29 | 31 | self.class.searchkick_index.reindex([self], method_name: method_name, mode: mode, refresh: refresh, single: true) |
30 | - end | |
32 | + end unless base.method_defined?(:reindex) | |
31 | 33 | |
32 | 34 | def similar(**options) |
33 | 35 | self.class.searchkick_index.similar_record(self, **options) |
34 | - end | |
36 | + end unless base.method_defined?(:similar) | |
35 | 37 | |
36 | 38 | def search_data |
37 | 39 | data = respond_to?(:to_hash) ? to_hash : serializable_hash |
... | ... | @@ -39,11 +41,11 @@ module Searchkick |
39 | 41 | data.delete("_id") |
40 | 42 | data.delete("_type") |
41 | 43 | data |
42 | - end | |
44 | + end unless base.method_defined?(:search_data) | |
43 | 45 | |
44 | 46 | def should_index? |
45 | 47 | true |
46 | - end | |
48 | + end unless base.method_defined?(:should_index?) | |
47 | 49 | end |
48 | 50 | |
49 | 51 | class_eval do | ... | ... |