Sha256: 6c2ff8e1b1800ee889dd841fa4d5d825e26dffc5d156f42f28415ffa22cd8953
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module SocialAvatarProxy class Configuration class Cache def read(options = {}) false end def write(file, options = {}) file end def fetch(options = {}, &block) # if the cache is enabled attempt read file = attempt_read(options) # if read fails yield the block # if the cache is enabled attempt write # return the block result unless file file = block.yield attempt_write(file, options) if file end # return the file file end def configure(&block) enable instance_eval(&block) end def disabled? !enabled? end def enabled? !!@enabled end private def disable @enabled = false end def enable @enabled = true end def attempt_read(options = {}) enabled? && read(options) end def attempt_write(file, options = {}) enabled? && write(file, options) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
social-avatar-proxy-2.0.1 | lib/social_avatar_proxy/configuration/cache.rb |
social-avatar-proxy-2.0.0 | lib/social_avatar_proxy/configuration/cache.rb |