lib/flapjack-diner/tools.rb
# copied from Rack::Utils -- builds the query string for GETs
copied from Rack::Utils -- builds the query string for GETs
copied from Rack :: Utils -- builds the query string for GETs
def build_nested_query(value, prefix = nil)
        if value.respond_to?(:iso8601)
          raise ArgumentError, "value must be a Hash" if prefix.nil?
          "#{prefix}=#{escape(value.iso8601)}"
        else
          case value
          when Array
            value.map { |v|
              build_nested_query(v, "#{prefix}[]")
            }.join("&")
          when Hash
            value.map { |k, v|
              build_nested_query(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k))
            }.join("&")
          when String, Integer
            raise ArgumentError, "value must be a Hash" if prefix.nil?
            "#{prefix}=#{escape(value.to_s)}"
          else
            prefix
          end
        end
      end
def build_nested_query ( value , prefix = nil ) if value . respond_to? ( :iso8601 ) raise ArgumentError , "value must be a Hash" if prefix . nil? "#{prefix}=#{escape(value.iso8601)}" else case value when Array value . map { | v | build_nested_query ( v , "#{prefix}[]" ) } . join ( "&" ) when Hash value . map { | k , v | build_nested_query ( v , prefix ? "#{prefix}[#{escape(k)}]" : escape ( k ) ) } . join ( "&" ) when String , Integer raise ArgumentError , "value must be a Hash" if prefix . nil? "#{prefix}=#{escape(value.to_s)}" else prefix end end end
copied from Rack::Utils -- builds the query string for GETs
copied from Rack :: Utils -- builds the query string for GETs
value
prefix