Class: Assets::Compiler::Plugin::Rack
- Inherits:
-
Object
- Object
- Assets::Compiler::Plugin::Rack
- Defined in:
- lib/assets/compiler/plugin/rack.rb
Instance Attribute Summary collapse
-
#dwell ⇒ Float
The delay, in seconds, between update checks.
Instance Method Summary collapse
-
#call(env) ⇒ (#to_i, {String => String}, Object)
The Rack response.
-
#initialize(app, dwell = 1.0) ⇒ Rack
constructor
Initialize the middleware.
Constructor Details
#initialize(app, dwell = 1.0) ⇒ Rack
Initialize the middleware.
17 18 19 20 21 |
# File 'lib/assets/compiler/plugin/rack.rb', line 17 def initialize(app, dwell = 1.0) @app = app @dwell = dwell @check_after = Time.now.to_f end |
Instance Attribute Details
#dwell ⇒ Float
The delay, in seconds, between update checks. Useful when many resources are requested for a single page. ‘nil` means no delay at all.
11 12 13 |
# File 'lib/assets/compiler/plugin/rack.rb', line 11 def dwell @dwell end |
Instance Method Details
#call(env) ⇒ (#to_i, {String => String}, Object)
Returns The Rack response.
25 26 27 28 29 30 31 |
# File 'lib/assets/compiler/plugin/rack.rb', line 25 def call(env) if @dwell.nil? || Time.now.to_f > @check_after Assets::Compiler.compile! @check_after = Time.now.to_f + @dwell if @dwell end @app.call(env) end |