Class: Ruco::FileStore

Inherits:
Object show all
Defined in:
lib/ruco/file_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(folder, options) ⇒ FileStore

Returns a new instance of FileStore.



5
6
7
8
# File 'lib/ruco/file_store.rb', line 5

def initialize(folder, options)
  @folder = folder
  @options = options
end

Instance Method Details

#get(key) ⇒ Object



16
17
18
19
# File 'lib/ruco/file_store.rb', line 16

def get(key)
  file = file(key)
  deserialize File.read(file) if File.exist?(file)
end

#set(key, value) ⇒ Object



10
11
12
13
14
# File 'lib/ruco/file_store.rb', line 10

def set(key, value)
  `mkdir -p #{@folder}` unless File.exist? @folder
  File.write(file(key), serialize(value))
  cleanup
end