class Figgy::Store

The backing object for a {Figgy} instance.

Public Class Methods

new(finder, config) click to toggle source
# File lib/figgy/store.rb, line 4
def initialize(finder, config)
  @finder = finder
  @config = config
  @cache  = {}
end

Public Instance Methods

get(key) click to toggle source

Retrieve the value for a key, expiring the cache and/or loading it if necessary.

@raise [Figgy::FileNotFound] if no config file could be found for name

# File lib/figgy/store.rb, line 14
def get(key)
  key = key.to_s
  @cache.delete(key) if @config.always_reload?
  if @cache.key?(key)
    @cache[key]
  else
    @cache[key] = @finder.load(key)
  end
end
keys() click to toggle source

@return [Array<String>] the list of currently loaded keys

# File lib/figgy/store.rb, line 25
def keys
  @cache.keys
end
size() click to toggle source

@return [Integer] the current size of the cache

# File lib/figgy/store.rb, line 30
def size
  @cache.size
end