Method: Pact::Hal::Link#with_query

Defined in:
lib/pact/hal/link.rb

#with_query(query) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/pact/hal/link.rb', line 74

def with_query(query)
  if query && query.any?
    uri = URI(href)
    existing_query_params = Rack::Utils.parse_nested_query(uri.query)
    uri.query = Rack::Utils.build_nested_query(existing_query_params.merge(query))
    new_attrs = attrs.merge('href' => uri.to_s)
    Link.new(new_attrs, http_client)
  else
    self
  end
end