File tree Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ module Parameters
31
31
# end
32
32
def use ( *names )
33
33
named_params = Grape ::DSL ::Configuration . stacked_hash_to_hash ( @api . namespace_stackable ( :named_params ) ) || { }
34
- options = names . last . is_a? ( Hash ) ? names . pop : { }
34
+ options = names . extract_options!
35
35
names . each do |name |
36
36
params_block = named_params . fetch ( name ) do
37
37
fail "Params :#{ name } not found!"
@@ -86,7 +86,7 @@ def use(*names)
86
86
def requires ( *attrs , &block )
87
87
orig_attrs = attrs . clone
88
88
89
- opts = attrs . last . is_a? ( Hash ) ? attrs . pop . clone : { }
89
+ opts = attrs . extract_options! . clone
90
90
opts [ :presence ] = true
91
91
92
92
if opts [ :using ]
@@ -105,7 +105,7 @@ def requires(*attrs, &block)
105
105
def optional ( *attrs , &block )
106
106
orig_attrs = attrs . clone
107
107
108
- opts = attrs . last . is_a? ( Hash ) ? attrs . pop . clone : { }
108
+ opts = attrs . extract_options! . clone
109
109
type = opts [ :type ]
110
110
111
111
# check type for optional parameter group
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ def rescue_from(*args, &block)
104
104
handler = block
105
105
end
106
106
107
- options = args . last . is_a? ( Hash ) ? args . pop : { }
107
+ options = args . extract_options!
108
108
handler ||= proc { options [ :with ] } if options . key? ( :with )
109
109
110
110
if args . include? ( :all )
Original file line number Diff line number Diff line change @@ -28,8 +28,7 @@ module ClassMethods
28
28
#
29
29
def version ( *args , &block )
30
30
if args . any?
31
- options = args . pop if args . last . is_a? Hash
32
- options ||= { }
31
+ options = args . extract_options!
33
32
options = { using : :path } . merge ( options )
34
33
35
34
fail Grape ::Exceptions ::MissingVendorOption . new if options [ :using ] == :header && !options . key? ( :vendor )
You can’t perform that action at this time.
0 commit comments