initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FO
|
||||
class Cache
|
||||
def initialize(init = {})
|
||||
@c = init
|
||||
end
|
||||
|
||||
def file!(path)
|
||||
if @c[path].nil?
|
||||
return @c[path] = File.read(path)
|
||||
end
|
||||
@c[path]
|
||||
end
|
||||
|
||||
def get(k)
|
||||
@c.fetch(k)
|
||||
end
|
||||
|
||||
def set!(k, v)
|
||||
@c[k] = v
|
||||
end
|
||||
|
||||
def set(k, v)
|
||||
self.class.new(@c.merge(k => v))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user