Class: Heliosphere::Indexer
- Inherits:
-
Object
- Object
- Heliosphere::Indexer
- Defined in:
- lib/heliosphere/indexer.rb
Constant Summary collapse
- SEARCH_WITHOUT_LIFECYCLE =
{ :auto_index => false, :auto_remove => false }
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
Instance Method Summary collapse
- #apply ⇒ Object
- #define(&block) ⇒ Object
- #index(model, &block) ⇒ Object
- #model_definitions ⇒ Object
- #model_names ⇒ Object
- #models ⇒ Object
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
11 12 13 |
# File 'lib/heliosphere/indexer.rb', line 11 def block @block end |
Instance Method Details
#apply ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/heliosphere/indexer.rb', line 22 def apply = SEARCH_WITHOUT_LIFECYCLE model_definitions.each do |model, block| model.instance_eval do searchable(, &block) end end end |
#define(&block) ⇒ Object
13 14 15 16 |
# File 'lib/heliosphere/indexer.rb', line 13 def define(&block) instance_eval(&block) apply end |
#index(model, &block) ⇒ Object
31 32 33 |
# File 'lib/heliosphere/indexer.rb', line 31 def index(model, &block) model_definitions[model] = block end |
#model_definitions ⇒ Object
39 40 41 |
# File 'lib/heliosphere/indexer.rb', line 39 def model_definitions @model_definitions ||= {} end |
#model_names ⇒ Object
18 19 20 |
# File 'lib/heliosphere/indexer.rb', line 18 def model_names models.map { |model| model.name.underscore.to_sym } end |
#models ⇒ Object
35 36 37 |
# File 'lib/heliosphere/indexer.rb', line 35 def models model_definitions.keys end |