Module: BangBang::Controller::Controllers
- Included in:
- BangBang::Controller
- Defined in:
- lib/bang-bang/controller.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#call!(env) ⇒ Object
Overrode call! to speed up routing to subresources.
Class Method Details
.included(mod) ⇒ Object
89 90 91 |
# File 'lib/bang-bang/controller.rb', line 89 def self.included(mod) mod.extend(ClassMethods) end |
Instance Method Details
#call!(env) ⇒ Object
Overrode call! to speed up routing to subresources.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/bang-bang/controller.rb', line 94 def call!(env) self.class.controllers.each do |controller| request = ::Sinatra::Request.new(env) routes = controller.routes[request.request_method] || [] path = unescape(request.path_info) routes.each do |pattern, keys, conditions, block| if pattern.match(path) subapp_instance = controller.allocate subapp_instance.send(:initialize, nil) response = subapp_instance.call(env) return response if response[0] != 404 end end end super end |