class XapianDb::IndexWriters::TransactionalWriter
Attributes
delete_requests[R]
index_requests[R]
Public Class Methods
new()
click to toggle source
Constructor
# File lib/xapian_db/index_writers/transactional_writer.rb 16 def initialize 17 @index_requests = [] 18 @delete_requests = [] 19 end
Public Instance Methods
commit_using(writer)
click to toggle source
Commit all pending changes to the database @param [DirectWriter, BeanstalkWriter] writer The writer to use
# File lib/xapian_db/index_writers/transactional_writer.rb 43 def commit_using(writer) 44 @index_requests.each { |obj| writer.index obj, false } 45 @delete_requests.each { |xapian_id| writer.delete_doc_with xapian_id, false } 46 XapianDb.database.commit 47 end
delete_doc_with(xapian_id, commit=false)
click to toggle source
Remove a document from the index @param [String] xapian_id The document id
# File lib/xapian_db/index_writers/transactional_writer.rb 29 def delete_doc_with(xapian_id, commit=false) 30 @delete_requests << xapian_id 31 end
index(obj, commit=false, changed_attrs: [])
click to toggle source
Update an object in the index @param [Object] obj An instance of a class with a blueprint configuration
# File lib/xapian_db/index_writers/transactional_writer.rb 23 def index(obj, commit=false, changed_attrs: []) 24 @index_requests << obj 25 end
reindex_class(klass, options={})
click to toggle source
Reindex all objects of a given class @param [Class] klass The class to reindex @param [Hash] options Options for reindexing @option options [Boolean] :verbose (false) Should the reindexing give status informations?
# File lib/xapian_db/index_writers/transactional_writer.rb 37 def reindex_class(klass, options={}) 38 raise "rebuild_xapian_index is not supported in transactions" 39 end