Sha256: 3252cac61ebfbb1d6819eb1f4d5148cc9dc06c92002fb577f7d62869ba6695a5

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

module Nitro

# Router mixin. Typically used to generate 'nice' urls.
# Nice urls are considered (?) more Search Engine 
# friendly.
	
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

# * George Moschovitis  <gm@navel.gr>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.20.0 lib/nitro/routing.rb