Method: PStore#initialize
- Defined in:
- lib/pstore.rb
#initialize(file, thread_safe = false) ⇒ PStore
Returns a new PStore object.
Argument file
is the path to the file in which objects are to be stored; if the file exists, it should be one that was written by PStore.
path = 't.store'
store = PStore.new(path)
A PStore object is reentrant. If argument thread_safe
is given as true
, the object is also thread-safe (at the cost of a small performance penalty):
store = PStore.new(path, true)
372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/pstore.rb', line 372 def initialize(file, thread_safe = false) dir = File::dirname(file) unless File::directory? dir raise PStore::Error, format("directory %s does not exist", dir) end if File::exist? file and not File::readable? file raise PStore::Error, format("file %s not readable", file) end @filename = file @abort = false @ultra_safe = false @thread_safe = thread_safe @lock = Thread::Mutex.new end |