module Rory::PathGeneration

Public Instance Methods

path_to(route_name, fields = {}) click to toggle source
# File lib/rory/path_generation.rb, line 3
def path_to(route_name, fields = {})
  if route = @app.routes.detect { |r| r.name == route_name }
    path = route.mask.dup.prepend('/').prepend(base_path.to_s)
    fields.each do |key, value|
      path.gsub!(/\:#{key}/, value.to_s)
    end
    path
  end
end