Sha256: 9c53889f2b05e6915091043ea5ac8821434a8ae9ebae015cd085cc045f650a91

Contents?: true

Size: 825 Bytes

Versions: 9

Compression:

Stored size: 825 Bytes

Contents

module Resources
  module Routes
    extend ActiveSupport::Concern
          
      included do
      end

      def routes
        Rails.application.routes || request.env['action_dispatch.routes']
      end

      def named_routes
        routes.named_routes
      end

      def router
        routes.router
      end

      def path_parameters
        request.env['action_dispatch.request.path_parameters'].symbolize_keys
      end

      def current_route
        recognize_route(request)
      end

      def current_path
        recognize_path(request.path)
      end



      protected

      def recognize_path(path)
        routes.recognize_path(path)
      end

      def recognize_route(request)
        router.recognize(request) do |route, matches, params|
          return route
        end
      end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
resources-1.1.1 lib/resources/routes.rb
resources-1.1.0 lib/resources/routes.rb
resources-1.0.1 lib/resources/routes.rb
resources-1.0.0 lib/resources/routes.rb
resources-0.2.0 lib/resources/routes.rb
resources-0.1.3 lib/resources/routes.rb
resources-0.1.2 lib/resources/routes.rb
resources-0.1.1 lib/resources/routes.rb
resources-0.1.0 lib/resources/routes.rb