Sha256: 6d1d6c697dfb5bf6183af4bbdb19d5a374258cfbca4a90361f0ff9da4dcce383

Contents?: true

Size: 834 Bytes

Versions: 4

Compression:

Stored size: 834 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

4 entries across 4 versions & 2 rubygems

Version Path
dpickett-amazon_associate-0.6.4 lib/amazon_associate/cache_factory.rb
dpickett-amazon_associate-0.6.5 lib/amazon_associate/cache_factory.rb
dpickett-amazon_associate-0.7.0 lib/amazon_associate/cache_factory.rb
amazon_associate-0.7.0 lib/amazon_associate/cache_factory.rb