Class: Dcha::Store::File

Inherits:
Hash
  • Object
show all
Defined in:
lib/dcha/store/file.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ File



5
6
7
8
# File 'lib/dcha/store/file.rb', line 5

def initialize(path)
  @path = Pathname.new(path).realdirpath
  Dir.mkdir(path) unless Dir.exist?(path)
end

Instance Method Details

#[](key) ⇒ Object



10
11
12
# File 'lib/dcha/store/file.rb', line 10

def [](key)
  super || load_from(key)
end

#[]=(key, value) ⇒ Object



14
15
16
17
# File 'lib/dcha/store/file.rb', line 14

def []=(key, value)
  save_to(key, value)
  super
end

#clear!Object



19
20
21
# File 'lib/dcha/store/file.rb', line 19

def clear!
  FileUtils.rm_rf(path)
end