class AmazonS3IndexProxy::Proxy

Attributes

index_file_url[R]
options[R]

Public Class Methods

new(index_file_url, cache_options={}) click to toggle source
# File lib/amazon_s3_index_proxy/proxy.rb, line 5
def initialize(index_file_url, cache_options={})
  @index_file_url = index_file_url
  @options = { expires_in: expires_in }.merge(cache_options)
end

Public Instance Methods

call() click to toggle source
# File lib/amazon_s3_index_proxy/proxy.rb, line 10
def call
  index_file
end

Private Instance Methods

cache_key() click to toggle source
# File lib/amazon_s3_index_proxy/proxy.rb, line 27
def cache_key
  [
    AmazonS3IndexProxy.cache_key_prefix,
    AmazonS3IndexProxy.index_file_url,
  ].join('\\')
end
expires_in() click to toggle source
# File lib/amazon_s3_index_proxy/proxy.rb, line 16
def expires_in
  AmazonS3IndexProxy.expires_in
end
fetch_index_file() click to toggle source
# File lib/amazon_s3_index_proxy/proxy.rb, line 34
def fetch_index_file
  Net::HTTP.get(index_file_uri)
end
index_file() click to toggle source
# File lib/amazon_s3_index_proxy/proxy.rb, line 20
def index_file
  Rails.cache.fetch(cache_key, options) do
    Rails.logger.info("Updating cached version of '#{index_file_url}'")
    fetch_index_file
  end
end
index_file_uri() click to toggle source
# File lib/amazon_s3_index_proxy/proxy.rb, line 38
def index_file_uri
  URI(index_file_url)
end