Module: SearchCraft::Model
- Defined in:
- lib/searchcraft/model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Class method to add a class to the list of included classes.
- .included_classes ⇒ Object
-
.refresh_all! ⇒ Object
Runs .refresh! on all classes that include SearchCraft::Model.
- .refresh_any_unpopulated! ⇒ Object
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
Class method to add a class to the list of included classes
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/searchcraft/model.rb', line 9 def self.included(base) if base.is_a?(Class) base.extend ClassMethods if base.is_a?(ClassMethods) && base.respond_to?(:table_name=) base.table_name = base.name.to_s.tableize.tr("/", "_") @included_classes << base unless @included_classes.include?(base) end end super end |
.included_classes ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/searchcraft/model.rb', line 43 def self.included_classes @included_classes | if SearchCraft.config.explicit_model_class_names SearchCraft.config.explicit_model_class_names.map(&:constantize) else [] end end |
.refresh_all! ⇒ Object
Runs .refresh! on all classes that include SearchCraft::Model
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/searchcraft/model.rb', line 23 def self.refresh_all! if SearchCraft.config.explicit_model_class_names.present? SearchCraft.config.explicit_model_class_names.each do |model_class_name| model_class_name.constantize.refresh! end else included_classes.each do |klass| if klass.is_a?(ClassMethods) klass.refresh! end end end end |
.refresh_any_unpopulated! ⇒ Object
37 38 39 40 41 |
# File 'lib/searchcraft/model.rb', line 37 def self.refresh_any_unpopulated! included_classes.each do |klass| klass.refresh! unless klass.populated? end end |
Instance Method Details
#read_only? ⇒ Boolean
102 103 104 |
# File 'lib/searchcraft/model.rb', line 102 def read_only? true end |