Module: ActsAsFerret::RdigAdapter::ClassMethods
- Defined in:
- lib/rdig_adapter.rb
Instance Method Summary collapse
-
#configure_rdig ⇒ Object
unfortunately need to modify global RDig.configuration because it’s used everywhere in RDig.
- #find_for_id(id) ⇒ Object
-
#find_with_ferret(q, options = {}, find_options = {}) ⇒ Object
overriding aaf to enforce loading page title and content from the ferret index.
-
#records_for_rebuild(batch_size = 1000, &block) ⇒ Object
overriding aaf to return the documents fetched via RDig.
-
#records_modified_since(time) ⇒ Object
overriding aaf to skip reindexing records changed during the rebuild when rebuilding with the rake task.
Instance Method Details
#configure_rdig ⇒ Object
unfortunately need to modify global RDig.configuration because it’s used everywhere in RDig
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rdig_adapter.rb', line 84 def configure_rdig # back up original config old_logger = RDig.logger old_cfg = RDig.configuration.dup RDig.logger = ActsAsFerret.logger rdig_configuration[:crawler].each { |k,v| RDig.configuration.crawler.send :"#{k}=", v } if rdig_configuration[:crawler] if ce_config = rdig_configuration[:content_extraction] RDig.configuration.content_extraction = OpenStruct.new( :hpricot => OpenStruct.new( ce_config ) ) end yield ensure # restore original config RDig.configuration.crawler = old_cfg.crawler RDig.configuration.content_extraction = old_cfg.content_extraction RDig.logger = old_logger end |
#find_for_id(id) ⇒ Object
108 109 110 |
# File 'lib/rdig_adapter.rb', line 108 def find_for_id(id) new id end |
#find_with_ferret(q, options = {}, find_options = {}) ⇒ Object
overriding aaf to enforce loading page title and content from the ferret index
103 104 105 106 |
# File 'lib/rdig_adapter.rb', line 103 def find_with_ferret(q, = {}, = {}) [:lazy] = true super end |
#records_for_rebuild(batch_size = 1000, &block) ⇒ Object
overriding aaf to return the documents fetched via RDig
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rdig_adapter.rb', line 61 def records_for_rebuild(batch_size = 1000, &block) indexer = Indexer.new(batch_size, self, &block) configure_rdig do crawler = RDig::Crawler.new RDig.configuration, ActsAsFerret::logger crawler.instance_variable_set '@indexer', indexer ActsAsFerret::logger.debug "now crawling..." crawler.crawl end rescue => e ActsAsFerret::logger.error e ActsAsFerret::logger.debug e.backtrace.join("\n") ensure indexer.close if indexer end |
#records_modified_since(time) ⇒ Object
overriding aaf to skip reindexing records changed during the rebuild when rebuilding with the rake task
78 79 80 |
# File 'lib/rdig_adapter.rb', line 78 def records_modified_since(time) [] end |