Class: Pact::QueryHash
Instance Method Summary
collapse
included, #symbolize_keys
#fix_all_the_things, #fix_json_formatting, #fix_regexp, #remove_unicode
Constructor Details
#initialize(query) ⇒ QueryHash
Returns a new instance of QueryHash.
11
12
13
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 11
def initialize(query)
@hash = query.nil? ? query : convert_to_hash_of_arrays(query)
end
|
Instance Method Details
#==(other) ⇒ Object
27
28
29
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 27
def ==(other)
QueryHash === other && other.query == query
end
|
#as_json(opts = {}) ⇒ Object
15
16
17
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 15
def as_json(opts = {})
@hash
end
|
#difference(other) ⇒ Object
other will always be a QueryString, not a QueryHash, as it will have ben created from the actual query string.
33
34
35
36
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 33
def difference(other)
require 'pact/matchers' Pact::Matchers.diff(query, symbolize_keys(CGI::parse(other.query)), allow_unexpected_keys: false)
end
|
#empty? ⇒ Boolean
46
47
48
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 46
def empty?
@hash && @hash.empty?
end
|
#eql?(other) ⇒ Boolean
23
24
25
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 23
def eql?(other)
self == other
end
|
#query ⇒ Object
38
39
40
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 38
def query
@hash
end
|
#to_hash ⇒ Object
50
51
52
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 50
def to_hash
@hash
end
|
#to_json(opts = {}) ⇒ Object
19
20
21
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 19
def to_json(opts = {})
as_json(opts).to_json(opts)
end
|
#to_s ⇒ Object
42
43
44
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 42
def to_s
@hash.inspect
end
|