Class: Rack::OAuth2::Server::Admin::Mount
- Inherits:
-
Object
- Object
- Rack::OAuth2::Server::Admin::Mount
- Defined in:
- lib/rack/oauth2/server/admin.rb
Overview
Rack module that mounts the specified class on the specified path, and passes all other request to the application.
Class Attribute Summary collapse
-
.klass ⇒ Object
readonly
Returns the value of attribute klass.
-
.match ⇒ Object
readonly
Returns the value of attribute match.
-
.path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Mount
constructor
A new instance of Mount.
Constructor Details
#initialize(app) ⇒ Mount
Returns a new instance of Mount.
31 32 33 34 |
# File 'lib/rack/oauth2/server/admin.rb', line 31 def initialize(app) @pass = app @admin = self.class.klass.new end |
Class Attribute Details
.klass ⇒ Object (readonly)
Returns the value of attribute klass.
28 29 30 |
# File 'lib/rack/oauth2/server/admin.rb', line 28 def klass @klass end |
.match ⇒ Object (readonly)
Returns the value of attribute match.
28 29 30 |
# File 'lib/rack/oauth2/server/admin.rb', line 28 def match @match end |
.path ⇒ Object (readonly)
Returns the value of attribute path.
28 29 30 |
# File 'lib/rack/oauth2/server/admin.rb', line 28 def path @path end |
Class Method Details
.mount(klass, path) ⇒ Object
22 23 24 25 26 |
# File 'lib/rack/oauth2/server/admin.rb', line 22 def mount(klass, path) @klass = klass @path = path @match = /^#{Regexp.escape(path)}(\/.*|$)?/ end |
Instance Method Details
#call(env) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rack/oauth2/server/admin.rb', line 36 def call(env) path = env["PATH_INFO"].to_s script_name = env['SCRIPT_NAME'] if path =~ self.class.match && rest = $1 env.merge! "SCRIPT_NAME"=>(script_name + self.class.path), "PATH_INFO"=>rest return @admin.call(env) else return @pass.call(env) end end |