Skip to content

Commit

Permalink
use correct params class in declared
Browse files Browse the repository at this point in the history
  • Loading branch information
thogg4 committed May 10, 2017
1 parent c644607 commit 61f0c8e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/grape/dsl/inside_route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def self.post_filter_methods(type)
# has completed
module PostBeforeFilter
def declared(passed_params, options = {}, declared_params = nil)
puts 'declared'
puts passed_params
puts passed_params.class

options = options.reverse_merge(include_missing: true, include_parent_namespaces: true)
declared_params ||= optioned_declared_params(options)

Expand All @@ -46,7 +50,7 @@ def declared_array(passed_params, options, declared_params)
end

def declared_hash(passed_params, options, declared_params)
declared_params.each_with_object({}) do |declared_param, memo|
declared_params.each_with_object(passed_params.class.new) do |declared_param, memo|
# If it is not a Hash then it does not have children.
# Find its value or set it to nil.
if !declared_param.is_a?(Hash)
Expand All @@ -56,7 +60,7 @@ def declared_hash(passed_params, options, declared_params)
declared_param.each_pair do |declared_parent_param, declared_children_params|
next unless options[:include_missing] || passed_params.key?(declared_parent_param)

passed_children_params = passed_params[declared_parent_param] || {}
passed_children_params = passed_params[declared_parent_param] || passed_params.class.new
memo[optioned_param_key(declared_parent_param, options)] = declared(passed_children_params, options, declared_children_params)
end
end
Expand Down

0 comments on commit 61f0c8e

Please sign in to comment.