Class: Lotus::Routing::Route Private

Inherits:
HttpRouter::Route
  • Object
show all
Defined in:
lib/lotus/routing/route.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Entry of the routing system

Examples:

require 'lotus/router'

router = Lotus::Router.new
router.get('/', to: endpoint) # => #<Lotus::Routing::Route:0x007f83083ba028 ...>

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#generate(resolver, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Asks the given resolver to return an endpoint that will be associated

with the other options.

Examples:

require 'lotus/router'

router = Lotus::Router.new
router.get('/', to: endpoint, as: :home_page).name # => :home_page

router.path(:home_page) # => '/'

Parameters:

  • resolver (Lotus::Routing::EndpointResolver, #resolve)

    this may change according to the :resolve option passed to Lotus::Router#initialize.

  • options (Hash) (defaults to: {})

    options to customize the route

Options Hash (options):

  • :as (Symbol)

    the name we want to use for the route

See Also:

Since:

  • 0.1.0



41
42
43
44
45
# File 'lib/lotus/routing/route.rb', line 41

def generate(resolver, options = {}, &endpoint)
  self.to   = resolver.resolve(options, &endpoint)
  self.name = options[:as].to_sym if options[:as]
  self
end

#nested_routerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Introspect the given route to understand if there is a wrapped Lotus::Router

Since:

  • 0.2.0



52
53
54
# File 'lib/lotus/routing/route.rb', line 52

def nested_router
  dest.routes if dest.respond_to?(:routes)
end