Sha256: d49b5c0be55181ff2d35ca9a1db1d8b44f42d37da7bce3630b037dabaeb21583
Contents?: true
Size: 692 Bytes
Versions: 2
Compression:
Stored size: 692 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 routes = subclasses.flat_map { |s| s.send(:prepare_routes) } # delete duplicate routes routes.delete_if do |route| all_options = routes.map { |r| r.instance_variable_get(:@options) } all_options.count(route.instance_variable_get(:@options)) > 1 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grape-route-helpers-1.2.1 | lib/grape-route-helpers/all_routes.rb |
grape-route-helpers-1.2.0 | lib/grape-route-helpers/all_routes.rb |