lib/restfulness/router.rb in restfulness-0.2.4 vs lib/restfulness/router.rb in restfulness-0.2.5

- old
+ new

@@ -1,18 +1,26 @@ module Restfulness class Router - attr_accessor :routes + attr_accessor :routes, :current_scope def initialize(&block) self.routes = [] + self.current_scope = [] instance_eval(&block) if block_given? end def add(*args) - routes << Route.new(*args) + routes << Route.new(*(current_scope + args)) + end + + def scope(*args, &block) + old_scope = current_scope + self.current_scope += args + instance_eval(&block) if block_given? + self.current_scope = old_scope end def route_for(path) parts = path.gsub(/^\/|\/$/, '').split(/\//) routes.each do |route|