Sha256: 96c573f7f0debe5358e8229c8744cddc6b87057d1f6b531ec719a7b38d2f2b85

Contents?: true

Size: 575 Bytes

Versions: 5

Compression:

Stored size: 575 Bytes

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id: routing.rb 1 2005-04-11 11:04:30Z gmosx $

module Nitro

# Router mixin.
	
module Router
	
	# The route table maps 'nice URLs' to real URLs that
	# can be handled by the Dispatcher.

	attr_accessor :routes

	# Apply routing rules to the path.

	def route(path, context)
		for rule, real_path, *params in @routes
			if md = path.match(rule)
				params.each_with_index do |p, idx|
					context[p] = md.captures[idx]
				end
				return real_path
			end
		end

		return path
	end

end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.16.0 lib/nitro/routing.rb
nitro-0.17.0 lib/nitro/routing.rb
nitro-0.18.0 lib/nitro/routing.rb
nitro-0.18.1 lib/nitro/routing.rb
nitro-0.19.0 lib/nitro/routing.rb