lib/simple_controller/router.rb in simple_controller-0.1.1 vs lib/simple_controller/router.rb in simple_controller-1.0.0
- old
+ new
@@ -1,55 +1,9 @@
-require 'simple_controller/router/mapper'
+require 'simple_controller/router/core'
+require 'simple_controller/router/context'
module SimpleController
class Router
- attr_reader :route_mapping, :route, :route_path, :controller_name_block
-
- include ActiveSupport::Callbacks
- define_callbacks :call
-
- def initialize
- @route_mapping = {}
- end
-
- def call(route_path, params={})
- @route_path = route_path.to_s
- @route = @route_mapping[@route_path]
-
- raise "#{self.class} route for '#{@route_path}' not found" unless route
-
- run_callbacks(:call) do
- @route.call params, controller_name_block
- end
- ensure
- @route_path = nil
- @route = nil
- end
-
- def route_paths
- route_mapping.keys
- end
-
- def draw(&block)
- mapper = Mapper.new(self)
- mapper.instance_eval(&block)
- end
-
- def add_route(route_path, route)
- @route_mapping[route_path] = route
- end
-
- def parse_controller_name(&block)
- @controller_name_block = block
- end
-
- class << self
- def instance
- @instance ||= new
- end
-
- def call(*args)
- instance.call(*args)
- end
- end
+ include Core
+ include Context
end
end
\ No newline at end of file