Class: Adva::Static::Server::Static

Inherits:
Rack::File
  • Object
show all
Defined in:
lib/adva/static/server/static.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, root) ⇒ Static

Returns a new instance of Static.



9
10
11
12
13
# File 'lib/adva/static/server/static.rb', line 9

def initialize(app, root)
  @app  = app
  @root = root
  Adva.out.puts "serving from #{root}"
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



7
8
9
# File 'lib/adva/static/server/static.rb', line 7

def app
  @app
end

#rootObject (readonly)

Returns the value of attribute root.



7
8
9
# File 'lib/adva/static/server/static.rb', line 7

def root
  @root
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/adva/static/server/static.rb', line 15

def call(env)
  if get?(env) && path = static(env)
    super(env.merge('PATH_INFO' => path))
  else
    app.call(env)
  end
end