Sha256: aa659168b5c574dd23af27616dacd0a5325f6221e45f159d0d58af6827e3e1b2

Contents?: true

Size: 941 Bytes

Versions: 5

Compression:

Stored size: 941 Bytes

Contents

require 'hanami/utils/string'

module Hanami
  module Action
    # Routing helper for full stack Hanami web applications.
    #
    # For a given application called <tt>Web::Application</tt>, at runtime
    # Hanami creates a routes factory called <tt>Web::Routes</tt>.
    #
    # Included by default in every controller.
    #
    # @since 0.3.2
    #
    # @example 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
    module RoutingHelpers
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanami-0.8.0 lib/hanami/action/routing_helpers.rb
hanami-0.7.3 lib/hanami/action/routing_helpers.rb
hanami-0.7.2 lib/hanami/action/routing_helpers.rb
hanami-0.7.1 lib/hanami/action/routing_helpers.rb
hanami-0.7.0 lib/hanami/action/routing_helpers.rb