Class: Sinatra::Sprockets::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/sprockets/server.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, engine, path_prefix) {|engine| ... } ⇒ Server

Returns a new instance of Server.

Yields:



7
8
9
10
11
12
# File 'lib/sinatra/sprockets/server.rb', line 7

def initialize(app, engine, path_prefix, &block)
  @app = app
  @engine = engine
  @path_prefix = path_prefix
  yield engine if block_given?
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



5
6
7
# File 'lib/sinatra/sprockets/server.rb', line 5

def app
  @app
end

#engineObject (readonly)

Returns the value of attribute engine.



5
6
7
# File 'lib/sinatra/sprockets/server.rb', line 5

def engine
  @engine
end

#path_prefixObject (readonly)

Returns the value of attribute path_prefix.



5
6
7
# File 'lib/sinatra/sprockets/server.rb', line 5

def path_prefix
  @path_prefix
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sinatra/sprockets/server.rb', line 14

def call(env)
  path = env["PATH_INFO"]
  if path =~ path_prefix and not engine.nil?
    env["PATH_INFO"].sub!(path_prefix, '')
    engine.call(env)
  else
    app.call(env)
  end
ensure
  env["PATH_INFO"] = path
end