Class: Static
- Inherits:
-
Object
- Object
- Static
- Defined in:
- lib/railz_lite/controllers/static.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#file_server ⇒ Object
readonly
Returns the value of attribute file_server.
-
#root_paths ⇒ Object
readonly
Returns the value of attribute root_paths.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Static
constructor
A new instance of Static.
Constructor Details
#initialize(app) ⇒ Static
Returns a new instance of Static.
6 7 8 9 10 |
# File 'lib/railz_lite/controllers/static.rb', line 6 def initialize(app) @app = app @root_paths = ['public', 'assets'] @file_server = FileServer.new end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/railz_lite/controllers/static.rb', line 4 def app @app end |
#file_server ⇒ Object (readonly)
Returns the value of attribute file_server.
4 5 6 |
# File 'lib/railz_lite/controllers/static.rb', line 4 def file_server @file_server end |
#root_paths ⇒ Object (readonly)
Returns the value of attribute root_paths.
4 5 6 |
# File 'lib/railz_lite/controllers/static.rb', line 4 def root_paths @root_paths end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/railz_lite/controllers/static.rb', line 12 def call(env) req = Rack::Request.new(env) path = req.path asset_dir = get_asset_dir(path) if asset_dir.nil? app.call(env) else file_server.call(env, asset_dir) end end |