Module: Lotus::Action::RoutingHelpers

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

Overview

Routing helper for full stack Lotus web applications.

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

Included by default in every controller.

Examples:

Usage in controller

require 'lotus'

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/lotus/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