Module: Atlasq::Cache

Defined in:
lib/atlasq/cache.rb

Class Method Summary collapse

Class Method Details

.get(full_name) ⇒ Object

Returns file.

Parameters:

  • full_name (String)

    namespace + file name (ex. “info/countries.json”)

Returns:

  • file



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/atlasq/cache.rb', line 12

def self.get(full_name)
  @get ||= {}
  @get.fetch(full_name) do
    path = "#{CACHE_DIR}/#{full_name}"

    content = File.read(path)
    content = JSON.parse(content) if full_name.end_with?(".json")

    @get[full_name] = content
  end
end