Module: SwitchSearchable::Searchable
- Defined in:
- lib/switch_searchable/searchable.rb
Defined Under Namespace
Modules: ClassMethods
Classes: BadConfiguration, RequiredMethodNotDefined
Class Method Summary
collapse
Class Method Details
.check_config ⇒ Object
19
20
21
22
23
24
|
# File 'lib/switch_searchable/searchable.rb', line 19
def check_config
raise(
BadConfiguration,
"Please add SEARCH_ENGINE in your environment variables"
) unless ENV["SEARCH_ENGINE"]
end
|
.check_methods(klass) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/switch_searchable/searchable.rb', line 26
def check_methods(klass)
raise(
RequiredMethodNotDefined,
":raise_errors method not defined in your search engine"
) unless "SwitchSearchable::SearchEngine::#{ENV["SEARCH_ENGINE"]}".
constantize.respond_to? :raise_errors
raise(
RequiredMethodNotDefined,
":search method not defined in your search engine"
) unless klass.respond_to? :search
raise(
RequiredMethodNotDefined,
":reindex_search_engine! method not defined in your search engine"
) unless klass.respond_to? :reindex_search_engine!
raise(
RequiredMethodNotDefined,
":init_search_engine method not defined in your search engine"
) unless klass.respond_to? :init_search_engine
end
|
.included(klass) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/switch_searchable/searchable.rb', line 7
def included(klass)
check_config
klass.class_eval do
extend ClassMethods
include "SwitchSearchable::SearchEngine::#{ENV["SEARCH_ENGINE"]}".
constantize
end
check_methods(klass)
end
|