Module: AlgoliaSearch::Utilities
- Defined in:
- lib/algoliasearch/utilities.rb
Class Method Summary collapse
- .clear_all_indexes ⇒ Object
- .get_model_classes ⇒ Object
- .reindex_all_models ⇒ Object
- .set_settings_all_models ⇒ Object
Class Method Details
.clear_all_indexes ⇒ Object
13 14 15 16 17 |
# File 'lib/algoliasearch/utilities.rb', line 13 def clear_all_indexes get_model_classes.each do |klass| klass.clear_index! end end |
.get_model_classes ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/algoliasearch/utilities.rb', line 4 def get_model_classes if Rails.application && defined?(Rails.autoloaders) && Rails.autoloaders.zeitwerk_enabled? Zeitwerk::Loader.eager_load_all elsif Rails.application Rails.application.eager_load! end AlgoliaSearch.instance_variable_get :@included_in end |
.reindex_all_models ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/algoliasearch/utilities.rb', line 19 def reindex_all_models klasses = get_model_classes puts '' puts "Reindexing #{klasses.count} models: #{klasses.to_sentence}." puts '' klasses.each do |klass| puts klass puts "Reindexing #{klass.count} records..." klass.algolia_reindex end end |
.set_settings_all_models ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/algoliasearch/utilities.rb', line 33 def set_settings_all_models klasses = get_model_classes puts '' puts "Pushing settings for #{klasses.count} models: #{klasses.to_sentence}." puts '' klasses.each do |klass| puts "Pushing #{klass} settings..." klass.algolia_set_settings end end |