Class: Sinatra::Sprockets::Server
- Inherits:
-
Object
- Object
- Sinatra::Sprockets::Server
- Defined in:
- lib/sinatra/sprockets/server.rb
Overview
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#engine ⇒ Object
readonly
Returns the value of attribute engine.
-
#path_prefix ⇒ Object
readonly
Returns the value of attribute path_prefix.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, engine, path_prefix) {|engine| ... } ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(app, engine, path_prefix) {|engine| ... } ⇒ Server
Returns a new instance of Server.
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
#app ⇒ Object (readonly)
Returns the value of attribute app.
5 6 7 |
# File 'lib/sinatra/sprockets/server.rb', line 5 def app @app end |
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
5 6 7 |
# File 'lib/sinatra/sprockets/server.rb', line 5 def engine @engine end |
#path_prefix ⇒ Object (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 |