Sha256: 21d93760fb5f4a5d345bb7779c059214fe4a9bcb97067edbc9ac1886a32a0a08

Contents?: true

Size: 623 Bytes

Versions: 6

Compression:

Stored size: 623 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

6 entries across 6 versions & 1 rubygems

Version Path
nitro-0.21.0 lib/nitro/routing.rb
nitro-0.21.2 lib/nitro/routing.rb
nitro-0.22.0 lib/nitro/routing.rb
nitro-0.25.0 lib/nitro/routing.rb
nitro-0.24.0 lib/nitro/routing.rb
nitro-0.23.0 lib/nitro/routing.rb