Class: Hyraft::PreloadedStatic
- Inherits:
-
Object
- Object
- Hyraft::PreloadedStatic
- Defined in:
- lib/hyraft/boot/preloaded_static.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ PreloadedStatic
constructor
A new instance of PreloadedStatic.
Constructor Details
#initialize(app, options = {}) ⇒ PreloadedStatic
Returns a new instance of PreloadedStatic.
6 7 8 9 |
# File 'lib/hyraft/boot/preloaded_static.rb', line 6 def initialize(app, = {}) @app = app @urls = [:urls] || ["/styles", "/css", "/images", "/js", "/favicon.ico"] end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hyraft/boot/preloaded_static.rb', line 11 def call(env) path = env['PATH_INFO'] # Check if this is a static asset we should handle if @urls.any? { |url| path.start_with?(url) } serve_preloaded_asset(path) else @app.call(env) end end |