File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,27 @@ module DSL
5
5
module Parameters
6
6
extend ActiveSupport ::Concern
7
7
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
8
29
def use ( *names )
9
30
named_params = Grape ::DSL ::Configuration . stacked_hash_to_hash ( @api . namespace_stackable ( :named_params ) ) || { }
10
31
options = names . last . is_a? ( Hash ) ? names . pop : { }
You can’t perform that action at this time.
0 commit comments