Module: Middleman::CoreExtensions::Request::ClassMethods
- Defined in:
- middleman-core/lib/middleman-core/core_extensions/request.rb
Instance Method Summary (collapse)
-
- (Rack::Builder) app
The shared Rack instance being build.
-
- (Object) call(env)
Call prototype, use in config.ru.
-
- (Middleman::Application) inst(&block)
Get the static instance.
-
- (void) inst=(inst)
Set the shared instance.
-
- (void) map(map, &block)
Add Rack App mapped to specific path.
-
- (Rack::Builder) prototype
Prototype app.
-
- (Object) reset!
Reset Rack setup.
-
- (Rack::Builder) to_rack_app(&block)
Return built Rack app.
-
- (void) use(middleware, *args, &block)
Use Rack middleware.
Instance Method Details
- (Rack::Builder) app
The shared Rack instance being build
45 46 47 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 45 def app @app ||= ::Rack::Builder.new end |
- (Object) call(env)
Call prototype, use in config.ru
101 102 103 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 101 def call(env) prototype.call(env) end |
- (Middleman::Application) inst(&block)
Get the static instance
53 54 55 56 57 58 59 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 53 def inst(&block) @inst ||= begin mm = new(&block) mm.run_hook :ready mm end end |
- (void) inst=(inst)
This method returns an undefined value.
Set the shared instance
66 67 68 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 66 def inst=(inst) @inst = inst end |
- (void) map(map, &block)
This method returns an undefined value.
Add Rack App mapped to specific path
118 119 120 121 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 118 def map(map, &block) @mappings ||= [] @mappings << [map, block] end |
- (Rack::Builder) prototype
Prototype app. Used in config.ru
94 95 96 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 94 def prototype @prototype ||= to_rack_app end |
- (Object) reset!
Reset Rack setup
36 37 38 39 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 36 def reset! @app = nil @prototype = nil end |
- (Rack::Builder) to_rack_app(&block)
Return built Rack app
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 74 def to_rack_app(&block) inner_app = inst(&block) (@middleware || []).each do |m| app.use(m[0], *m[1], &m[2]) end app.map("/") { run inner_app } (@mappings || []).each do |m| app.map(m[0], &m[1]) end app end |
- (void) use(middleware, *args, &block)
This method returns an undefined value.
Use Rack middleware
109 110 111 112 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 109 def use(middleware, *args, &block) @middleware ||= [] @middleware << [middleware, args, block] end |