Sha256: 6755ba220c0e815d40c65df8e7189e1e032ce1e15e37e5b9fe2b01234a9b0443

Contents?: true

Size: 461 Bytes

Versions: 2

Compression:

Stored size: 461 Bytes

Contents

module GrapeRouteHelpers
  # methods to extend Grape::API's behavior so it can get a
  # list of routes from all APIs and decorate them with
  # the DecoratedRoute class
  module AllRoutes
    def decorated_routes
      # memoize so that construction of decorated routes happens once
      @decorated_routes ||= all_routes.map { |r| DecoratedRoute.new(r) }
    end

    def all_routes
      subclasses.flat_map { |s| s.send(:prepare_routes) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grape-route-helpers-1.0.1 lib/grape-route-helpers/all_routes.rb
grape-route-helpers-1.0.0 lib/grape-route-helpers/all_routes.rb