Class: Scorched::Static
- Inherits:
-
Object
- Object
- Scorched::Static
- Defined in:
- lib/scorched/static.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #file_server ⇒ Object protected
-
#initialize(app, dir = 'public') ⇒ Static
constructor
A new instance of Static.
Constructor Details
#initialize(app, dir = 'public') ⇒ Static
Returns a new instance of Static.
3 4 5 |
# File 'lib/scorched/static.rb', line 3 def initialize(app, dir = 'public') @app, @dir = app, dir end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 |
# File 'lib/scorched/static.rb', line 7 def call(env) response = file_server.call(env) response[0] >= 400 ? @app.call(env) : response end |
#file_server ⇒ Object (protected)
14 15 16 |
# File 'lib/scorched/static.rb', line 14 def file_server @file_server ||= Rack::File.new(@dir) end |