Sha256: e1905e619445eae4532a11fbb50f548cc34a0752e0de11db4e2edf9adf99a4bc
Contents?: true
Size: 631 Bytes
Versions: 6
Compression:
Stored size: 631 Bytes
Contents
module GrapePathHelpers # 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) } .sort_by { |r| -r.dynamic_path_segments.count } end def all_routes routes = descendants.flat_map { |s| s.send(:prepare_routes) } routes.uniq { |r| r.options.merge(path: r.path) } end end end
Version data entries
6 entries across 6 versions & 1 rubygems