Sha256: 2f03b7516ea64efed0b5d1116e35c6c397e7ccc6a5386bf267c172db2d2fe9ca
Contents?: true
Size: 1.13 KB
Versions: 5
Compression:
Stored size: 1.13 KB
Contents
module AgnosticBackend class Indexer attr_reader :index def initialize(index) @index = index end # Sends the specified document to the remote backend. # This is a template method. # @param [Indexable] an Indexable object # @returns [boolean] true if success, false if failure # returns nil if no indexing attempt is made (e.g. generated document is empty) def put(indexable) document = indexable.generate_document return if document.blank? begin publish(transform(prepare(document))) true rescue => e false end end # Deletes the specified document from the index, This is an abstract # method which concrete index classes must implement in order to provide # its functionality. # @param [document_id] the document id of the indexed document def delete(document_id) raise NotImplementedError end private def publish(document) raise NotImplementedError end def transform(document) raise NotImplementedError end def prepare(document) raise NotImplementedError end end end
Version data entries
5 entries across 5 versions & 1 rubygems