Method: NoSE::Backend::FileBackend#initialize
- Defined in:
- lib/nose/backend/file.rb
#initialize(model, indexes, plans, update_plans, config) ⇒ FileBackend
Returns a new instance of FileBackend.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/nose/backend/file.rb', line 9 def initialize(model, indexes, plans, update_plans, config) super # Try to load data from file or start fresh @index_data = if !config[:file].nil? && File.file?(config[:file]) Marshal.load File.open(config[:file]) else {} end # Ensure the data is saved when we exit ObjectSpace.define_finalizer self, self.class.finalize(@index_data, config[:file]) end |