Class: Scorched::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/scorched/static.rb

Instance Method Summary collapse

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_serverObject (protected)



14
15
16
# File 'lib/scorched/static.rb', line 14

def file_server
  @file_server ||= Rack::File.new(@dir)
end