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,16 +22,18 @@ module Searchkick | ||
22 | raise ArgumentError, "Invalid value for callbacks" | 22 | raise ArgumentError, "Invalid value for callbacks" |
23 | end | 23 | end |
24 | 24 | ||
25 | + base = self | ||
26 | + | ||
25 | mod = Module.new | 27 | mod = Module.new |
26 | include(mod) | 28 | include(mod) |
27 | mod.module_eval do | 29 | mod.module_eval do |
28 | def reindex(method_name = nil, mode: nil, refresh: false) | 30 | def reindex(method_name = nil, mode: nil, refresh: false) |
29 | self.class.searchkick_index.reindex([self], method_name: method_name, mode: mode, refresh: refresh, single: true) | 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 | def similar(**options) | 34 | def similar(**options) |
33 | self.class.searchkick_index.similar_record(self, **options) | 35 | self.class.searchkick_index.similar_record(self, **options) |
34 | - end | 36 | + end unless base.method_defined?(:similar) |
35 | 37 | ||
36 | def search_data | 38 | def search_data |
37 | data = respond_to?(:to_hash) ? to_hash : serializable_hash | 39 | data = respond_to?(:to_hash) ? to_hash : serializable_hash |
@@ -39,11 +41,11 @@ module Searchkick | @@ -39,11 +41,11 @@ module Searchkick | ||
39 | data.delete("_id") | 41 | data.delete("_id") |
40 | data.delete("_type") | 42 | data.delete("_type") |
41 | data | 43 | data |
42 | - end | 44 | + end unless base.method_defined?(:search_data) |
43 | 45 | ||
44 | def should_index? | 46 | def should_index? |
45 | true | 47 | true |
46 | - end | 48 | + end unless base.method_defined?(:should_index?) |
47 | end | 49 | end |
48 | 50 | ||
49 | class_eval do | 51 | class_eval do |