Class: NetMate::Dispatcher
- Inherits:
-
Object
- Object
- NetMate::Dispatcher
- Defined in:
- lib/net_mate/dispatcher.rb
Instance Method Summary collapse
- #dispatch ⇒ Object
-
#initialize(url, method, params) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
Constructor Details
#initialize(url, method, params) ⇒ Dispatcher
Returns a new instance of Dispatcher.
4 5 6 |
# File 'lib/net_mate/dispatcher.rb', line 4 def initialize(url, method, params) @url, @method, @params = url, method.downcase, params end |
Instance Method Details
#dispatch ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/net_mate/dispatcher.rb', line 8 def dispatch controller, action = NetMate::routes[[@url, @method]] if controller controller = Object.const_get("#{controller.capitalize}Controller").new controller.instance_variable_set(:@params, @params) controller.send(action) #controller.send(:render, action.to_s) else Response.new(IO.read("#{ROOT_PATH}/public/404.html")).error end end |