class Ransack::Search

def collapse_multiparameter_attributes!(attrs)

def collapse_multiparameter_attributes!(attrs)
  attrs.keys.each do |k|
    if k.include?(Constants::LEFT_PARENTHESIS)
      real_attribute, position = k.split(/\(|\)/)
      cast =
      if Constants::A_S_I.include?(position.last)
        position.last
      else
        nil
      end
      position = position.to_i - 1
      value = attrs.delete(k)
      attrs[real_attribute] ||= []
      attrs[real_attribute][position] =
      if cast
        if value.blank? && cast == Constants::I
          nil
        else
          value.send("to_#{cast}")
        end
      else
        value
      end
    elsif Hash === attrs[k]
      collapse_multiparameter_attributes!(attrs[k])
    end
  end
  attrs
end