module SwitchSearchable::Searchable
Public Class Methods
check_config()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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