Sha256: 472ffa2fce1155dfc43a227261d8d3b45f03eab8d076479f772c8782e55a30c3

Contents?: true

Size: 573 Bytes

Versions: 4

Compression:

Stored size: 573 Bytes

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id: routing.rb 271 2005-03-07 17:56:45Z gmosx $

module N

# 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

4 entries across 4 versions & 1 rubygems

Version Path
nitro-0.12.0 lib/nitro/routing.rb
nitro-0.13.0 lib/nitro/routing.rb
nitro-0.14.0 lib/nitro/routing.rb
nitro-0.15.0 lib/nitro/routing.rb