Module: MongoidXapian::Indexer
- Defined in:
- lib/mongoid-xapian/indexer.rb
Class Method Summary collapse
Class Method Details
.add(doc) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/mongoid-xapian/indexer.rb', line 3 def self.add(doc) on_db(doc) do xapian_doc = documents.add(doc.to_xapian) doc.set(:xapian_id, xapian_doc.id) end end |
.remove(doc) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/mongoid-xapian/indexer.rb', line 21 def self.remove(doc) if doc.xapian_id on_db(doc) do documents.delete(doc.xapian_id) end end end |
.update(doc) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mongoid-xapian/indexer.rb', line 10 def self.update(doc) if doc.xapian_id on_db(doc) do xapian_doc = XapianFu::XapianDoc.new(doc.to_xapian.merge(:id => doc.xapian_id), :xapian_db => self) xapian_doc.save end else add(doc) end end |