class ShuntCache::Status

Constants

SHUNTED
UNSHUNTED

Attributes

cache[RW]
key[RW]
logger[RW]

Public Class Methods

configure() { |instance| ... } click to toggle source
# File lib/shunt_cache/status.rb, line 16
def self.configure
  yield instance
end

Public Instance Methods

clear!() click to toggle source

reset to default

# File lib/shunt_cache/status.rb, line 31
def clear!
  cache.delete(key)
end
shunt!() click to toggle source
# File lib/shunt_cache/status.rb, line 35
def shunt!
  log(:info, "Shunting site with key: #{key}")
  cache.write(key, SHUNTED)
end
shunted?() click to toggle source
# File lib/shunt_cache/status.rb, line 26
def shunted?
  status == SHUNTED
end
status() click to toggle source
# File lib/shunt_cache/status.rb, line 20
def status
  cache.fetch(key) do
    UNSHUNTED
  end
end
unshunt!() click to toggle source
# File lib/shunt_cache/status.rb, line 40
def unshunt!
  log(:info, "Unshunting site with key: #{key}")
  cache.write(key, UNSHUNTED)
end

Private Instance Methods

log(level, msg) click to toggle source
# File lib/shunt_cache/status.rb, line 47
def log(level, msg)
  logger.send(level, msg) if logger
end