Used to define the url mappings for child aliases within a namespace Invokes map on the application itself, appending the namespace to the route ::new(@app, :admin).map(:show).to(‘/admin/show’) is equivalent to ::new(@app, :admin, :show).to(‘/admin/show’)
# File lib/padrino-routing/named_route.rb, line 24 def map(*args, &block) @app.map(*args.unshift(@names), &block) end
Used to define the url mapping to the supplied alias Appends the application name to front of route if necessary ::new(@app, :account).to(‘/account/path’)
# File lib/padrino-routing/named_route.rb, line 15 def to(path) @names.unshift(@app.app_name.to_sym) unless @names.first == @app.app_name.to_sym @app.named_paths[@names] = path end
Constructs the NamedRoute which accepts the application and the route alias names to register (i.e [:account] or [:admin, :show]) ::new(@app, :admin, :show)
# File lib/padrino-routing/named_route.rb, line 7 def initialize(app, *names) @app = app @names = names.flatten end