From cb9a5284d7aecd958ec50fa03bde2641ea8b0a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 1 Oct 2015 21:50:55 -0300 Subject: [PATCH] Expose a method to override the SassProcessor cache store Sometimes you want to use a different cache than the sprockets cache to store the SASS cache. So I'm exposing a method so subclasses can override without having to override the entire `call` method. --- lib/sprockets/sass_processor.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/sprockets/sass_processor.rb b/lib/sprockets/sass_processor.rb index 69ca50b8d..065156bbd 100644 --- a/lib/sprockets/sass_processor.rb +++ b/lib/sprockets/sass_processor.rb @@ -39,8 +39,8 @@ def self.cache_key # Public: Initialize template with custom options. # # options - Hash - # cache_version - String custom cache version. Used to force a cache - # change after code changes are made to Sass Functions. + # cache_version - String custom cache version. Used to force a cache + # change after code changes are made to Sass Functions. # def initialize(options = {}, &block) @cache_version = options[:cache_version] @@ -59,7 +59,7 @@ def call(input) options = { filename: input[:filename], syntax: self.class.syntax, - cache_store: CacheStore.new(input[:cache], @cache_version), + cache_store: build_cache_store(input, @cache_version), load_paths: input[:environment].paths, sprockets: { context: context, @@ -84,6 +84,18 @@ def call(input) context.metadata.merge(data: css, sass_dependencies: sass_dependencies) end + # Public: Build the cache store to be used by the Sass engine. + # + # input - the input hash. + # version - the cache version. + # + # Override this method if you need to use a different cache than the + # Sprockets cache. + def build_cache_store(input, version) + CacheStore.new(input[:cache], version) + end + private :build_cache_store + # Public: Functions injected into Sass context during Sprockets evaluation. # # This module may be extended to add global functionality to all Sprockets