module Middleman::CoreExtensions::Request::ClassMethods
Public Instance Methods
app()
click to toggle source
The shared Rack instance being build
@private @return [Rack::Builder]
# File lib/middleman-core/core_extensions/request.rb, line 46 def app @app ||= ::Rack::Builder.new end
call(env)
click to toggle source
Call prototype, use in config.ru
@private
# File lib/middleman-core/core_extensions/request.rb, line 103 def call(env) prototype.call(env) end
inst(&block)
click to toggle source
Get the static instance
@private @return [Middleman::Application]
# File lib/middleman-core/core_extensions/request.rb, line 54 def inst(&block) @inst ||= begin mm = new(&block) mm.run_hook :ready mm end end
inst=(inst)
click to toggle source
Set the shared instance
@private @param [Middleman::Application] inst @return [void]
# File lib/middleman-core/core_extensions/request.rb, line 67 def inst=(inst) @inst = inst end
map(map, &block)
click to toggle source
Add Rack App mapped to specific path
@param [String] map Path to map @return [void]
# File lib/middleman-core/core_extensions/request.rb, line 120 def map(map, &block) @mappings ||= [] @mappings << [map, block] end
prototype()
click to toggle source
Prototype app. Used in config.ru
@private @return [Rack::Builder]
# File lib/middleman-core/core_extensions/request.rb, line 95 def prototype reset! to_rack_app end
reset!()
click to toggle source
Reset Rack setup
@private
# File lib/middleman-core/core_extensions/request.rb, line 38 def reset! @app = nil end
to_rack_app(&block)
click to toggle source
Return built Rack app
@private @return [Rack::Builder]
# File lib/middleman-core/core_extensions/request.rb, line 75 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
use(middleware, *args, &block)
click to toggle source
Use Rack middleware
@param [Class] middleware Middleware module @return [void]
# File lib/middleman-core/core_extensions/request.rb, line 111 def use(middleware, *args, &block) @middleware ||= [] @middleware << [middleware, args, block] end