lib/loquor/api_calls/index.rb in loquor-0.7.0 vs lib/loquor/api_calls/index.rb in loquor-0.8.0

- old
+ new

@@ -50,10 +50,20 @@ end def generate_url query_string = [] @criteria.each do |key,value| + add_criteria(query_string, key, value) + end + "#{klass.path}?#{query_string.join("&")}" + end + + def add_criteria(query_string, key, value) + substitute_value = Loquor.config.substitute_values[value] + if !substitute_value.nil? + query_string << "#{key}=#{URI.encode(substitute_value)}" + else case value when String, Symbol, Numeric query_string << "#{key}=#{URI.encode(value.to_s)}" when Array value.each do |v| @@ -61,9 +71,8 @@ end else raise LoquorError.new("Filter values must be strings or arrays.") end end - "#{klass.path}?#{query_string.join("&")}" end end end