Sha256: bfd727b88402a6019f53de265b0e18c60c1ee38d1e83fbf217022488a0f602ce

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

module AmazonAssociate
  class CacheFactory
    def self.cache(request, response, strategy)
      strategy_class_hash[strategy].cache(request, response)
    end
  
    def self.initialize_options(options)
      #check for a valid caching strategy
      unless self.strategy_class_hash.keys.include?(options[:caching_strategy])
        raise AmazonAssociate::ConfigurationError, "Invalid caching strategy" 
      end
      strategy_class_hash[options[:caching_strategy]].initialize_options(options)
    end
  
    def self.get(request, strategy)
      strategy_class_hash[strategy].get(request)
    end
  
    def self.sweep(strategy)
      strategy_class_hash[strategy].sweep
    end
  
    private
    def self.strategy_class_hash
      {
        :filesystem => AmazonAssociate::CachingStrategy::Filesystem
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dpickett-amazon_associate-0.6.1 lib/amazon_associate/cache_factory.rb
dpickett-amazon_associate-0.6.2 lib/amazon_associate/cache_factory.rb
dpickett-amazon_associate-0.6.3 lib/amazon_associate/cache_factory.rb