Class: Sprockets::LazyCompressor
- Inherits:
-
Object
- Object
- Sprockets::LazyCompressor
- 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
- #compress(content) ⇒ Object
-
#initialize(&block) ⇒ LazyCompressor
constructor
Initializes a new LazyCompressor.
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 |