Class: GrapeSwagger::Endpoint::ParamsParser
- Inherits:
-
Object
- Object
- GrapeSwagger::Endpoint::ParamsParser
- Defined in:
- lib/grape-swagger/endpoint/params_parser.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params, settings) ⇒ ParamsParser
constructor
A new instance of ParamsParser.
- #parse_request_params ⇒ Object
Constructor Details
#initialize(params, settings) ⇒ ParamsParser
Returns a new instance of ParamsParser.
12 13 14 15 |
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 12 def initialize(params, settings) @params = params @settings = settings end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 6 def params @params end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
6 7 8 |
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 6 def settings @settings end |
Class Method Details
.parse_request_params(params, settings) ⇒ Object
8 9 10 |
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 8 def self.parse_request_params(params, settings) new(params, settings).parse_request_params end |
Instance Method Details
#parse_request_params ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 17 def parse_request_params array_keys = [] public_params.each_with_object({}) do |(name, ), memo| name = name.to_s param_type = [:type] param_type = param_type.to_s unless param_type.nil? if param_type_is_array?(param_type) array_keys << name [:is_array] = true name += '[]' if array_use_braces?() else keys = array_keys.find_all { |key| name.start_with? "#{key}[" } if keys.any? [:is_array] = true if array_use_braces?() keys.sort.reverse_each do |key| name = name.sub(key, "#{key}[]") end end end end memo[name] = unless %w[Hash Array].include?(param_type) && !.key?(:documentation) end end |