Class: Paradeiser::Router
- Inherits:
-
Object
- Object
- Paradeiser::Router
- Defined in:
- lib/paradeiser/router.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #dispatch(command) ⇒ Object
-
#initialize ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize ⇒ Router
Returns a new instance of Router.
7 8 9 |
# File 'lib/paradeiser/router.rb', line 7 def initialize @status = 0 end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/paradeiser/router.rb', line 5 def status @status end |
Instance Method Details
#dispatch(command) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/paradeiser/router.rb', line 11 def dispatch(command) Proc.new do |args, | parts = command.name.split resource = parts.shift controller_name = "#{resource.pluralize.capitalize}Controller".to_sym if Paradeiser.const_defined?(controller_name) verb = parts.join controller_class = Paradeiser.const_get(controller_name) else verb = resource controller_class = ParadeiserController end controller = controller_class.new(verb) controller.call(args, ) @status = controller.exitstatus end end |