Skip to content

Commit

Permalink
Expose a method to override the SassProcessor cache store
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rafaelfranca committed Oct 2, 2015
1 parent f3e64e1 commit cb9a528
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/sprockets/sass_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit cb9a528

Please sign in to comment.