Class: ThinkingSphinx::Context
- Inherits:
-
Object
- Object
- ThinkingSphinx::Context
- Defined in:
- lib/thinking_sphinx/context.rb
Instance Attribute Summary (collapse)
-
- (Object) indexed_models
readonly
Returns the value of attribute indexed_models.
Instance Method Summary (collapse)
- - (Object) add_indexed_model(model)
- - (Object) define_indexes
-
- (Context) initialize(*models)
constructor
A new instance of Context.
- - (Object) prepare
- - (Object) superclass_indexed_models
Constructor Details
- (Context) initialize(*models)
A new instance of Context
4 5 6 |
# File 'lib/thinking_sphinx/context.rb', line 4 def initialize(*models) @indexed_models = [] end |
Instance Attribute Details
- (Object) indexed_models (readonly)
Returns the value of attribute indexed_models
2 3 4 |
# File 'lib/thinking_sphinx/context.rb', line 2 def indexed_models @indexed_models end |
Instance Method Details
- (Object) add_indexed_model(model)
25 26 27 28 29 30 31 |
# File 'lib/thinking_sphinx/context.rb', line 25 def add_indexed_model(model) model = model.name if model.is_a?(Class) indexed_models << model indexed_models.uniq! indexed_models.sort! end |
- (Object) define_indexes
19 20 21 22 23 |
# File 'lib/thinking_sphinx/context.rb', line 19 def define_indexes indexed_models.each { |model| model.constantize.define_indexes } end |
- (Object) prepare
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/thinking_sphinx/context.rb', line 8 def prepare ThinkingSphinx::Configuration.instance.indexed_models.each do |model| add_indexed_model model end return unless indexed_models.empty? load_models add_indexed_models end |
- (Object) superclass_indexed_models
33 34 35 36 37 38 |
# File 'lib/thinking_sphinx/context.rb', line 33 def superclass_indexed_models klasses = indexed_models.collect { |name| name.constantize } klasses.reject { |klass| klass.superclass.ancestors.any? { |ancestor| klasses.include?(ancestor) } }.collect { |klass| klass.name } end |