Sha256: 584004ce9b9cc6998e0b77cba69590cea9a71af4c6c997359c265c6d0afde048
Contents?: true
Size: 666 Bytes
Versions: 1
Compression:
Stored size: 666 Bytes
Contents
module Restfulness class Router 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(*(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| return route if route.handles?(parts) end nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restfulness-0.2.5 | lib/restfulness/router.rb |