Class: Droonga::Catalog::Modifier

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/catalog/modifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(source_catalog) ⇒ Modifier

Returns a new instance of Modifier.



25
26
27
28
# File 'lib/droonga/catalog/modifier.rb', line 25

def initialize(source_catalog)
  @generator = Catalog::Generator.new
  @generator.load(source_catalog)
end

Instance Method Details

#modifyObject



30
31
32
33
34
35
# File 'lib/droonga/catalog/modifier.rb', line 30

def modify
  SafeFileWriter.write(Path.catalog) do |output, file|
    yield(@generator, file)
    output.puts(JSON.pretty_generate(@generator.generate))
  end
end