Initial commit
This commit is contained in:
18
lib/http/query.rb
Normal file
18
lib/http/query.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module Pruning
|
||||
module HTTP
|
||||
class Query < Struct.new(:name, :indicator_ids)
|
||||
def initialize(params = {})
|
||||
values = members.map do |member|
|
||||
value = params.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 :name then value.to_s.gsub(/[^A-Za-z]/,'')
|
||||
else value
|
||||
end
|
||||
end
|
||||
super(*values)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user