def page_url(url)
      define_method(:page_url) do |query_params = {}|
        uri = URI(url)
        existing_params = URI.decode_www_form(uri.query || '')
        new_params = query_params.to_a

        unless existing_params.empty? && new_params.empty?
          combined_params = existing_params.push(*new_params)
          uri.query = URI.encode_www_form(combined_params)
        end

        uri.to_s
      end
    end
def page_url(url)
      define_method(:page_url) do |query_params = {}|
        uri = URI(url)
        existing_params = URI.decode_www_form(uri.query || '')
        new_params = query_params.to_a

        unless existing_params.empty? && new_params.empty?
          combined_params = existing_params.push(*new_params)
          uri.query = URI.encode_www_form(combined_params)
        end

        uri.to_s
      end
    end
Defines an instance method `page_url` which returns the url passed to this
 method and takes optional query parameters that will be appended to the
 url if given.

 @param url [String] the page url
 @return [Symbol] the name of the defined method (ruby 2.1+)