29 lines
390 B
Ruby
29 lines
390 B
Ruby
# 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
|