Class: Rad::Assets::StaticFiles

Inherits:
Rack::File
  • Object
show all
Defined in:
lib/rad/assets/static_files.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, filter = nil) ⇒ StaticFiles

Returns a new instance of StaticFiles.



2
3
4
# File 'lib/rad/assets/static_files.rb', line 2

def initialize(app, filter = nil)
  @app, @filter = app, filter
end

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/rad/assets/static_files.rb', line 6

def call(env)
  path = env["PATH_INFO"]

  if path != '/' and (!@filter or (@filter and @filter =~ path)) and (resolved_path = find_file(path))
    @path = resolved_path
    serving(env)
  else
    @app.call(env)
  end
end