lib/rackamole/mole.rb in rackamole-0.3.8 vs lib/rackamole/mole.rb in rackamole-0.3.9

- old
+ new

@@ -382,16 +382,23 @@ return stash[key] = value if !options[:mole_excludes] or options[:mole_excludes].empty? stash[key] = (options[:mole_excludes].include?( key ) ? nil : value) end # filters out params hash and convert values to json - def filter_params( source, excludes ) - results = BSON::OrderedHash.new - source.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |k| - results[k.to_sym] = source[k].to_json unless excludes.include?( k.to_sym ) - end - results + def filter_params( source, excludes, nest=false ) + results = nest ? {} : BSON::OrderedHash.new + source.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |k| + unless excludes.include? k.to_sym + results[k.to_sym] = if source[k].is_a?(Hash) + filter_params( source[k], excludes, true) + else + source[k] + end + results[k.to_sym] = results[k.to_sym].to_json unless nest + end + end + results end # Trim stack trace def trim_stack( boom ) boom.backtrace[0...4] @@ -431,6 +438,6 @@ # puts "%s %-#{40-level}s %s" % [ ' '*level, k, value.inspect ] # end # end # end end -end \ No newline at end of file +end