Skip to content

Commit

Permalink
Really remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
arfl committed Jan 14, 2016
1 parent 0aea435 commit 4b0595e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/grape-route-helpers/all_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ def decorated_routes
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
routes.uniq do |route|
route.instance_variable_get(:@options)
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/support/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class API < Grape::API
'pong'
end

get 'ping' do
'pong'
end

resource :cats do
get '/' do
%w(cats cats cats)
Expand Down

0 comments on commit 4b0595e

Please sign in to comment.