Skip to content

Commit 5b9cd71

Browse files
committed
Add comment documentation for Parameters#use
1 parent fa3ce9a commit 5b9cd71

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/grape/dsl/parameters.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ module DSL
55
module Parameters
66
extend ActiveSupport::Concern
77

8+
# Include reusable params rules among current.
9+
# You can define reusable params with helpers method.
10+
#
11+
# @example
12+
#
13+
# class API < Grape::API
14+
# helpers do
15+
# params :pagination do
16+
# optional :page, type: Integer
17+
# optional :per_page, type: Integer
18+
# end
19+
# end
20+
#
21+
# desc "Get collection"
22+
# params do
23+
# use :pagination
24+
# end
25+
# get do
26+
# Collection.page(params[:page]).per(params[:per_page])
27+
# end
28+
# end
829
def use(*names)
930
named_params = Grape::DSL::Configuration.stacked_hash_to_hash(@api.namespace_stackable(:named_params)) || {}
1031
options = names.last.is_a?(Hash) ? names.pop : {}

0 commit comments

Comments
 (0)