module SearchEnjoy::Dumping::ClassMethods
Attributes
search_index_state[R]
Public Instance Methods
dump_index_to_file()
click to toggle source
# File lib/search_enjoy/dumping.rb, line 14 def dump_index_to_file path = index_configuration.dump_dir_path filename = index_configuration.dump_filename FileUtils.mkdir_p(path) unless File.exist? path File.open("#{path}/#{filename}", 'w') do |file| file.write(@search_index.to_json) end end
increase_dump_counter()
click to toggle source
# File lib/search_enjoy/dumping.rb, line 38 def increase_dump_counter @search_index_state[:dump_counter] += 1 end
initialize_dump_counter()
click to toggle source
# File lib/search_enjoy/dumping.rb, line 34 def initialize_dump_counter @search_index_state[:dump_counter] = 0 end
load_index_from_file()
click to toggle source
# File lib/search_enjoy/dumping.rb, line 25 def load_index_from_file path = index_configuration.dump_dir_path filename = index_configuration.dump_filename File.open("#{path}/#{filename}", 'r') do |file| search_index.load_json(file.read) end end
need_dump?()
click to toggle source
# File lib/search_enjoy/dumping.rb, line 42 def need_dump? raise DumpException, "Index doesn't exist" if @search_index.nil? @search_index_state[:dump_counter] >= index_configuration.dump_frequency && index_configuration.dump_enable rescue StandardError => e e.message end