class Static
Attributes
app[R]
file_server[R]
root_paths[R]
Public Class Methods
new(app)
click to toggle source
# File lib/railz_lite/controllers/static.rb, line 6 def initialize(app) @app = app @root_paths = ['public', 'assets'] @file_server = FileServer.new end
Public Instance Methods
call(env)
click to toggle source
# 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
Private Instance Methods
get_asset_dir(path)
click to toggle source
return the root directory of asset request ex => 'films/assets/app.css' would return 'assets'
# File lib/railz_lite/controllers/static.rb, line 28 def get_asset_dir(path) root_paths.each { |root| return root if path.include?(root) } nil end