Sha256: c8830b4be83ed9cfef593a638b0555cc060b65004607f2b9e4f570b9601a3b7a

Contents?: true

Size: 496 Bytes

Versions: 3

Compression:

Stored size: 496 Bytes

Contents

module ActiveLucene
  class Writer < IndexWriter
    include Index

    def initialize
      overwrite = Dir[PATH + '/*'].size < 1
      super directory, Analyzer.new, overwrite, IndexWriter::MaxFieldLength::UNLIMITED
      yield self
      close
    end

    def self.write(document)
      new do |index|
        index.add_document document
      end
    end

    def self.delete(id)
      new do |index|
        index.delete_documents ActiveLucene::Term.for(ID, id)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_lucene-0.5.2 lib/active_lucene/writer.rb
active_lucene-0.5.1 lib/active_lucene/writer.rb
active_lucene-0.5.0 lib/active_lucene/writer.rb