lib/picky/backends/memory/basic.rb in picky-3.2.0 vs lib/picky/backends/memory/basic.rb in picky-3.3.0
- old
+ new
@@ -20,12 +20,14 @@
attr_reader :cache_path
# An index cache takes a path, without file extension,
# which will be provided by the subclasses.
#
- def initialize cache_path
+ def initialize cache_path, options = {}
@cache_path = "#{cache_path}.memory.#{extension}"
+ @empty = options[:empty]
+ @initial = options[:initial]
end
# The default extension for index files is "index".
#
def extension
@@ -34,10 +36,16 @@
# The empty index that is used for putting the index
# together before it is dumped into the files.
#
def empty
- {}
+ @empty && @empty.clone || {}
+ end
+
+ # The initial content before loading from file.
+ #
+ def initial
+ @initial && @initial.clone || {}
end
# Will copy the index file to a location that
# is in a directory named "backup" right under
# the directory the index file is in.
\ No newline at end of file