Class: Hanami::Routing::Route Private

Inherits:
HttpRouter::Route
  • Object
show all
Defined in:
lib/hanami/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 'hanami/router'

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

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initializeRoute

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.

Returns a new instance of Route.

Since:

  • 0.7.0



22
23
24
25
# File 'lib/hanami/routing/route.rb', line 22

def initialize(*)
  super
  @name = nil
end

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 'hanami/router'

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

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

Parameters:

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

    this may change according to the :resolve option passed to Hanami::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



49
50
51
52
53
# File 'lib/hanami/routing/route.rb', line 49

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 router that has an inspector

Since:

  • 0.2.0



60
61
62
# File 'lib/hanami/routing/route.rb', line 60

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