Class: XapianDb::Indexer
- Inherits:
-
Object
- Object
- XapianDb::Indexer
- Defined in:
- lib/xapian_db/indexer.rb
Overview
The indexer creates a Xapian::Document from an object. They object must be an instance of a class that has a blueprint configuration.
Instance Method Summary collapse
-
#build_document_for(obj) ⇒ Xapian::Document
Build the document for an object.
-
#initialize(database, document_blueprint) ⇒ Indexer
constructor
Constructor.
Constructor Details
#initialize(database, document_blueprint) ⇒ Indexer
Constructor
13 14 15 |
# File 'lib/xapian_db/indexer.rb', line 13 def initialize(database, document_blueprint) @database, @document_blueprint = database, document_blueprint end |
Instance Method Details
#build_document_for(obj) ⇒ Xapian::Document
Build the document for an object. The object must respond to ‘xapian_id’. The configured adapter should implement this method.
20 21 22 23 24 25 26 27 28 |
# File 'lib/xapian_db/indexer.rb', line 20 def build_document_for(obj) @obj = obj @blueprint = DocumentBlueprint.blueprint_for(@obj.class.name) @xapian_doc = Xapian::Document.new @xapian_doc.data = @obj.xapian_id store_fields index_text @xapian_doc end |