Class: Rack::Acme::FileCache

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/acme/file_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileCache

Returns a new instance of FileCache.



7
8
9
# File 'lib/rack/acme/file_cache.rb', line 7

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/rack/acme/file_cache.rb', line 5

def path
  @path
end

Instance Method Details

#[](token) ⇒ Object



11
12
13
14
15
# File 'lib/rack/acme/file_cache.rb', line 11

def [](token)
  dest = File.expand_path(token, path)

  File.read(dest) if File.exists?(dest)
end

#[]=(token, value) ⇒ Object



17
18
19
20
21
# File 'lib/rack/acme/file_cache.rb', line 17

def []=(token, value)
  dest = File.expand_path(token, path)

  File.write(dest, value)
end