Class: Marquery::AssetHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/marquery/asset_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, *directories) ⇒ AssetHandler

Returns a new instance of AssetHandler.



8
9
10
11
# File 'lib/marquery/asset_handler.rb', line 8

def initialize(app, *directories)
  @app = app
  @roots = directories.flatten.compact.map { resolve_root(_1) }.compact
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/marquery/asset_handler.rb', line 13

def call(env)
  path = env["PATH_INFO"].to_s
  if (resolved = serveable_path(path))
    serve_file(resolved)
  else
    @app.call(env)
  end
end