lib/hanami/routes.rb in hanami-1.0.0.beta2 vs lib/hanami/routes.rb in hanami-1.0.0.beta3
- old
+ new
@@ -5,18 +5,20 @@
#
# A Hanami application has this factory instantiated by default and associated
# to the `Routes` constant, under the application namespace.
#
# @since 0.1.0
+ # @api private
class Routes
# Initialize the factory
#
# @param routes [Hanami::Router] a routes set
#
# @return [Hanami::Routes] the factory
#
# @since 0.1.0
+ # @api private
def initialize(routes)
@routes = routes
end
# Return a relative path for the given route name
@@ -34,43 +36,43 @@
# @see http://rdoc.info/gems/hanami-router/Hanami/Router#path-instance_method
#
# @example Basic example
# require 'hanami'
#
- # module Bookshelf
+ # module Web
# class Application < Hanami::Application
# configure do
# routes do
# get '/login', to: 'sessions#new', as: :login
# end
# end
# end
# end
#
- # Bookshelf::Routes.path(:login)
+ # Web.routes.path(:login)
# # => '/login'
#
- # Bookshelf::Routes.path(:login, return_to: '/dashboard')
+ # Web.routes.path(:login, return_to: '/dashboard')
# # => '/login?return_to=%2Fdashboard'
#
# @example Dynamic finders
# require 'hanami'
#
- # module Bookshelf
+ # module Web
# class Application < Hanami::Application
# configure do
# routes do
# get '/login', to: 'sessions#new', as: :login
# end
# end
# end
# end
#
- # Bookshelf::Routes.login_path
+ # Web.routes.login_path
# # => '/login'
#
- # Bookshelf::Routes.login_path(return_to: '/dashboard')
+ # Web.routes.login_path(return_to: '/dashboard')
# # => '/login?return_to=%2Fdashboard'
def path(name, *args)
Utils::Escape::SafeString.new(@routes.path(name, *args))
end
@@ -89,11 +91,11 @@
# @see http://rdoc.info/gems/hanami-router/Hanami/Router#url-instance_method
#
# @example Basic example
# require 'hanami'
#
- # module Bookshelf
+ # module Web
# class Application < Hanami::Application
# configure do
# routes do
# scheme 'https'
# host 'bookshelf.org'
@@ -102,20 +104,20 @@
# end
# end
# end
# end
#
- # Bookshelf::Routes.url(:login)
+ # Web.routes.url(:login)
# # => 'https://bookshelf.org/login'
#
- # Bookshelf::Routes.url(:login, return_to: '/dashboard')
+ # Web.routes.url(:login, return_to: '/dashboard')
# # => 'https://bookshelf.org/login?return_to=%2Fdashboard'
#
# @example Dynamic finders
# require 'hanami'
#
- # module Bookshelf
+ # module Web
# class Application < Hanami::Application
# configure do
# routes do
# scheme 'https'
# host 'bookshelf.org'
@@ -124,13 +126,13 @@
# end
# end
# end
# end
#
- # Bookshelf::Routes.login_url
+ # Web.routes.login_url
# # => 'https://bookshelf.org/login'
#
- # Bookshelf::Routes.login_url(return_to: '/dashboard')
+ # Web.routes.login_url(return_to: '/dashboard')
# # => 'https://bookshelf.org/login?return_to=%2Fdashboard'
def url(name, *args)
Utils::Escape::SafeString.new(@routes.url(name, *args))
end