Sha256: 04dd0608b9a8946b2634c802df68e41ae4c10551691c1d2246ca0efa1030eb4c
Contents?: true
Size: 882 Bytes
Versions: 2
Compression:
Stored size: 882 Bytes
Contents
require 'singleton' require 'forwardable' module ShuntCache class Status include Singleton class << self extend Forwardable def_delegators :instance, :shunt!, :unshunt!, :status, :shunted?, :clear! end attr_accessor :key, :cache, :logger SHUNTED = "shunted" UNSHUNTED = "ok" def self.configure yield instance end def status cache.fetch(key) do UNSHUNTED end end def shunted? status == SHUNTED end # reset to default def clear! cache.delete(key) end def shunt! log(:info, "Shunting site with key: #{key}") cache.write(key, SHUNTED) end def unshunt! log(:info, "Unshunting site with key: #{key}") cache.write(key, UNSHUNTED) end private def log(level, msg) logger.send(level, msg) if logger end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shunt_cache-0.1.0 | lib/shunt_cache/status.rb |
shunt_cache-0.0.2 | lib/shunt_cache/status.rb |