class SocialAvatarProxy::Configuration::Cache

Public Instance Methods

configure(&block) click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 26
def configure(&block)
  enable
  instance_eval(&block)
end
disabled?() click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 31
def disabled?
  !enabled?
end
enabled?() click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 35
def enabled?
  !!@enabled
end
fetch(options = {}, &block) click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 12
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
read(options = {}) click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 4
def read(options = {})
  false
end
write(file, options = {}) click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 8
def write(file, options = {})
  file
end

Private Instance Methods

attempt_read(options = {}) click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 48
def attempt_read(options = {})
  enabled? && read(options)
end
attempt_write(file, options = {}) click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 52
def attempt_write(file, options = {})
  enabled? && write(file, options)
end
disable() click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 40
def disable
  @enabled = false
end
enable() click to toggle source
# File lib/social_avatar_proxy/configuration/cache.rb, line 44
def enable
  @enabled = true
end