DFS is working

This commit is contained in:
Senad Uka
2018-08-13 12:48:47 +02:00
parent de58457ef9
commit 92cadb76ed
3 changed files with 29 additions and 14 deletions

View File

@@ -2,11 +2,12 @@ module Pruning
module HTTP
class Query < Struct.new(:name, :indicator_ids)
def initialize(params = {})
symbolised = params.map { |k, v| { k.to_sym => v } }.reduce({}, :merge)
values = members.map do |member|
value = params.fetch(member, nil)
value = symbolised.fetch(member, nil)
next if value.nil?
case member
when :indicator_ids then value.map(&:to_i) # break on purpose if indicator_ids is not an array
when :indicator_ids then value.map(&->(indicator_id) { indicator_id.to_i } ) # break on purpose if indicator_ids is not an array
when :name then value.to_s.gsub(/[^A-Za-z]/,'')
else value
end