Class: Pakada::Dispatch
- Inherits:
-
Object
- Object
- Pakada::Dispatch
- Includes:
- Module
- Defined in:
- lib/pakada/dispatch/module.rb,
lib/pakada/dispatch/version.rb,
lib/pakada/dispatch/controller.rb,
lib/pakada/dispatch.rb
Defined Under Namespace
Modules: Controller, Module
Constant Summary collapse
- VERSION =
"0.2.3"
Instance Attribute Summary collapse
-
#router ⇒ Object
readonly
Returns the value of attribute router.
Instance Method Summary collapse
- #boot ⇒ Object
- #hooks ⇒ Object
-
#initialize ⇒ Dispatch
constructor
A new instance of Dispatch.
- #request(env) ⇒ Object
Constructor Details
#initialize ⇒ Dispatch
Returns a new instance of Dispatch.
14 15 16 17 18 19 20 21 22 |
# File 'lib/pakada/dispatch.rb', line 14 def initialize @router = HttpRouter.new Pakada.safety(Controller).extend Hooked Pakada.safety(Controller).around(:included) {|inner, klass| klass.send :include, Hooked klass.extend Hooked inner.call klass } end |
Instance Attribute Details
#router ⇒ Object (readonly)
Returns the value of attribute router.
12 13 14 |
# File 'lib/pakada/dispatch.rb', line 12 def router @router end |
Instance Method Details
#boot ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/pakada/dispatch.rb', line 28 def boot Pakada.modules.each_value {|mod| mod.extend Pakada.safety(::Pakada::Dispatch::Module) mod.load_controllers mod.routes if mod.respond_to? :routes } end |
#hooks ⇒ Object
24 25 26 |
# File 'lib/pakada/dispatch.rb', line 24 def hooks Pakada.instance.instead_of(:request) {|env| request env } end |
#request(env) ⇒ Object
36 37 38 |
# File 'lib/pakada/dispatch.rb', line 36 def request(env) router.call env end |