Module: Hanami::Action::RoutingHelpers Private

Defined in:
lib/hanami/action/routing_helpers.rb

Overview

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

Routing helper for full stack Hanami web applications.

For a given application called Web::Application, at runtime Hanami creates a routes factory called Web::Routes.

Included by default in every controller.

Examples:

Usage in controller

require 'hanami'

module Web::Controllers::Protected
  class Index
    include Web::Action

    def call(params)
      redirect_to routes.root_path
    end
  end
end

Since:

  • 0.3.2

Class Method Summary collapse

Class Method Details

.included(base) ⇒ 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.

Since:

  • 0.3.2



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hanami/action/routing_helpers.rb', line 27

def self.included(base)
  factory = "#{Utils::String.namespace(base)}.routes"

  base.class_eval <<-END_EVAL, __FILE__, __LINE__
    private

    def routes
      #{factory}
    end
  END_EVAL
end