Class: XapianDb::IndexWriters::ResqueWorker

Inherits:
Object
  • Object
show all
Extended by:
Utilities
Defined in:
lib/xapian_db/index_writers/resque_worker.rb

Overview

Worker to update the Xapian index; the worker will be called by resque and uses the DirectWriter to do the real work

Author:

  • Michael Stämpfli

Constant Summary collapse

APPROVED_TASKS =
[:index, :delete_doc, :reindex_class]

Class Method Summary collapse

Methods included from Utilities

assert_valid_keys, camelize, constantize

Class Method Details

.delete_doc(options) ⇒ Object


28
29
30
# File 'lib/xapian_db/index_writers/resque_worker.rb', line 28

def delete_doc(options)
  DirectWriter.delete_doc_with options['xapian_id']
end

.index(options) ⇒ Object


22
23
24
25
26
# File 'lib/xapian_db/index_writers/resque_worker.rb', line 22

def index(options)
  klass = constantize options['class']
  obj   = klass.respond_to?('get') ? klass.get(options['id']) : klass.find(options['id'])
  DirectWriter.index obj, true, changed_attrs: options[:changed_attrs]
end

.perform(task, options) ⇒ Object


18
19
20
# File 'lib/xapian_db/index_writers/resque_worker.rb', line 18

def perform(task, options)
  send(task, options) if APPROVED_TASKS.include?(task.to_sym)
end

.queueObject


14
15
16
# File 'lib/xapian_db/index_writers/resque_worker.rb', line 14

def queue
  XapianDb::Config.resque_queue
end

.reindex_class(options) ⇒ Object


32
33
34
35
# File 'lib/xapian_db/index_writers/resque_worker.rb', line 32

def reindex_class(options)
  klass = constantize options['class']
  DirectWriter.reindex_class klass, :verbose => false
end