Sha256: f6637e79662df6d5bdca6bc9c7cb79e8d039c1565acc09b09175aa9e7c601714

Contents?: true

Size: 952 Bytes

Versions: 7

Compression:

Stored size: 952 Bytes

Contents

module GrapePathHelpers
  # class for displaying the path, helper method name,
  # and required arguments for every Grape::Route.
  class RouteDisplayer
    def route_attributes
      Grape::API::Instance.decorated_routes.map do |route|
        {
          route_path: route.route_path,
          route_method: route.route_method,
          helper_names: route.helper_names,
          helper_arguments: route.helper_arguments
        }
      end
    end

    def display
      puts("== GRAPE ROUTE HELPERS ==\n\n")
      route_attributes.each do |attributes|
        printf("%s: %s\n", 'Verb', attributes[:route_method])
        printf("%s: %s\n", 'Path', attributes[:route_path])
        printf("%s: %s\n",
               'Helper Method',
               attributes[:helper_names].join(', '))
        printf("%s: %s\n",
               'Arguments',
               attributes[:helper_arguments].join(', '))
        puts("\n")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
grape-path-helpers-1.6.3 lib/grape-path-helpers/route_displayer.rb
grape-path-helpers-1.6.2 lib/grape-path-helpers/route_displayer.rb
grape-path-helpers-1.6.1 lib/grape-path-helpers/route_displayer.rb
grape-path-helpers-1.6.0 lib/grape-path-helpers/route_displayer.rb
grape-path-helpers-1.5.0 lib/grape-path-helpers/route_displayer.rb
grape-path-helpers-1.4.0 lib/grape-path-helpers/route_displayer.rb
grape-path-helpers-1.3.0 lib/grape-path-helpers/route_displayer.rb