lib/simple_controller/router/route.rb in simple_controller-0.1.1 vs lib/simple_controller/router/route.rb in simple_controller-1.0.0
- old
+ new
@@ -1,20 +1,18 @@
module SimpleController
class Router
class Route
- attr_reader :controller_name, :action_name
- attr_accessor :controller_name_block
+ attr_reader :controller_path, :action_name
- def initialize(controller_name, action_name)
- @controller_name, @action_name = controller_name, action_name
+ def initialize(controller_path, action_name)
+ @controller_path, @action_name = controller_path, action_name
end
- def controller(controller_name_block=nil)
- controller_name_block ? controller_name_block.call(controller_name) : "#{controller_name}_controller".classify.constantize
- end
+ def call(params, context, controller_path_block)
+ controller_class = controller_path_block ? controller_path_block.call(controller_path) : "#{controller_path}_controller".classify.constantize
- def call(params, controller_name_block=nil)
- controller(controller_name_block).call action_name, params
+ params = { 'controller' => controller_path, 'action' => action_name }.reverse_merge(params)
+ controller_class.call action_name, params, context
end
end
end
end
\ No newline at end of file