Class: Sprockets::LazyCompressor

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/compressors.rb

Overview

An asset compressor which only initializes the underlying compression engine when needed.

This postpones the initialization of the compressor until #compress is called the first time.

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ LazyCompressor

Initializes a new LazyCompressor.

The block should return a compressor when called, i.e. an object which responds to #compress.



69
70
71
# File 'lib/sprockets/compressors.rb', line 69

def initialize(&block)
  @block = block
end

Instance Method Details

#compress(content) ⇒ Object



73
74
75
# File 'lib/sprockets/compressors.rb', line 73

def compress(content)
  compressor.compress(content)
end