File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed
lib/rspec_api_documentation/dsl Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -148,20 +148,23 @@ def delete_extra_param(key)
148
148
149
149
def set_param ( hash , param )
150
150
key = param [ :name ]
151
- return hash if ! respond_to? ( key ) || in_path? ( key )
151
+ return hash if in_path? ( key )
152
152
153
- if scope = param [ :scope ]
154
- if scope . is_a? ( Array )
155
- hash . merge! ( scope . reverse . inject ( { key => send ( key ) } ) { |a , n | { n . to_s => a } } )
156
- else
157
- hash [ scope . to_s ] ||= { }
158
- hash [ scope . to_s ] [ key ] = send ( key )
159
- end
160
- else
161
- hash [ key ] = send ( key )
153
+ keys = [ param [ :scope ] , key ] . flatten . compact
154
+ method_name = keys . join ( '_' )
155
+
156
+ unless respond_to? ( method_name )
157
+ method_name = key
158
+ return hash unless respond_to? ( method_name )
162
159
end
163
160
164
- hash
161
+ hash . deep_merge ( build_param_hash ( keys , method_name ) )
165
162
end
163
+
164
+ def build_param_hash ( keys , method_name )
165
+ value = keys [ 1 ] ? build_param_hash ( keys [ 1 ..-1 ] , method_name ) : send ( method_name )
166
+ { keys [ 0 ] . to_s => value }
167
+ end
168
+
166
169
end
167
170
end
You can’t perform that action at this time.
0 commit comments