Class: AgnosticBackend::Indexer
- Inherits:
-
Object
- Object
- AgnosticBackend::Indexer
- Defined in:
- lib/agnostic_backend/indexer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#delete(document_id) ⇒ Object
Deletes the specified document from the index, This is an abstract method which concrete index classes must implement in order to provide its functionality.
-
#initialize(index) ⇒ Indexer
constructor
A new instance of Indexer.
-
#put(indexable) ⇒ Object
Sends the specified document to the remote backend.
Constructor Details
#initialize(index) ⇒ Indexer
Returns a new instance of Indexer.
6 7 8 |
# File 'lib/agnostic_backend/indexer.rb', line 6 def initialize(index) @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
4 5 6 |
# File 'lib/agnostic_backend/indexer.rb', line 4 def index @index end |
Instance Method Details
#delete(document_id) ⇒ Object
Deletes the specified document from the index, This is an abstract method which concrete index classes must implement in order to provide its functionality.
30 31 32 |
# File 'lib/agnostic_backend/indexer.rb', line 30 def delete(document_id) raise NotImplementedError end |
#put(indexable) ⇒ Object
Sends the specified document to the remote backend. This is a template method. returns nil if no indexing attempt is made (e.g. generated document is empty)
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/agnostic_backend/indexer.rb', line 15 def put(indexable) document = indexable.generate_document return if document.blank? begin publish(transform(prepare(document))) true rescue => e false end end |