Class: MongoidSphinx::Context
- Inherits:
-
Object
- Object
- MongoidSphinx::Context
- Defined in:
- lib/mongoid_sphinx/context.rb
Instance Attribute Summary collapse
-
#indexed_models ⇒ Object
readonly
Returns the value of attribute indexed_models.
Instance Method Summary collapse
- #add_indexed_model(model) ⇒ Object
- #define_indexes ⇒ Object
-
#initialize(*models) ⇒ Context
constructor
A new instance of Context.
- #prepare ⇒ Object
Constructor Details
#initialize(*models) ⇒ Context
Returns a new instance of Context.
4 5 6 |
# File 'lib/mongoid_sphinx/context.rb', line 4 def initialize(*models) @indexed_models = [] end |
Instance Attribute Details
#indexed_models ⇒ Object (readonly)
Returns the value of attribute indexed_models.
2 3 4 |
# File 'lib/mongoid_sphinx/context.rb', line 2 def indexed_models @indexed_models end |
Instance Method Details
#add_indexed_model(model) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/mongoid_sphinx/context.rb', line 24 def add_indexed_model(model) model = model.name if model.is_a?(Class) indexed_models << model indexed_models.uniq! indexed_models.sort! end |
#define_indexes ⇒ Object
18 19 20 21 22 |
# File 'lib/mongoid_sphinx/context.rb', line 18 def define_indexes indexed_models.each { |model| model.constantize.define_indexes } end |
#prepare ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/mongoid_sphinx/context.rb', line 8 def prepare MongoidSphinx::Configuration.instance.indexed_models.each do |model| add_indexed_model model end return unless indexed_models.empty? load_models end |