Class: Rack::Queries::App::Static
- Inherits:
-
Object
- Object
- Rack::Queries::App::Static
- Defined in:
- lib/rack/queries/app.rb
Constant Summary collapse
- STATIC =
::File.('static', __dir__)
- FILES =
Dir[::File.join(STATIC, '*')].map do |path| "/#{::File.basename(path)}" end
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Static
constructor
A new instance of Static.
Constructor Details
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
50 51 52 |
# File 'lib/rack/queries/app.rb', line 50 def app @app end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
50 51 52 |
# File 'lib/rack/queries/app.rb', line 50 def server @server end |
Instance Method Details
#call(env) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/rack/queries/app.rb', line 57 def call(env) if env[PATH_INFO] == '/' render_index(env) elsif FILES.include?(env[PATH_INFO]) server.call(env) else app.call(env) end end |