Module: Hanami::Action::RoutingHelpers

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

Overview

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

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.new(base).namespace}.routes"

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

    def routes
      #{factory}
    end
  END_EVAL
end