Skip to content

Commit

Permalink
Introduce Route#hidden for use in grape-swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
namusyaka committed Apr 9, 2016
1 parent c898153 commit 96eade9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/grape/router/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def route_path
pattern.path
end

def hidden
@options[:hidden] || (settings[:description] && settings[:description][:hidden])
end

def route_hidden
warn_route_methods(:hidden, caller(1).shift)
hidden
end

def initialize(method, pattern, options = {})
@suffix = options[:suffix]
@options = options.merge(method: method.to_s.upcase)
Expand Down
10 changes: 10 additions & 0 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,16 @@ def static
{ description: 'second method', params: {} }
]
end
it 'describes hidden accessor' do
subject.desc 'hidden as a description', hidden: true
subject.get :first do; end
subject.desc 'hidden as a route option'
subject.get :first, hidden: true do; end
first = subject.routes.shift
second = subject.routes.shift
expect(first.hidden).to be_truthy
expect(second.hidden).to be_truthy
end
it 'resets desc' do
subject.desc 'first method'
subject.get :first do; end
Expand Down

0 comments on commit 96eade9

Please sign in to comment.