Class: Pact::QueryHash
Constant Summary
Constants included
from Matchers
Matchers::DEFAULT_OPTIONS, Matchers::NO_DIFF, Matchers::NO_DIFF_AT_INDEX
Instance Method Summary
collapse
included, #symbolize_keys
Methods included from Matchers
#diff, #type_diff
#fix_all_the_things, #fix_json_formatting, #fix_regexp, #remove_unicode
Constructor Details
#initialize(query) ⇒ QueryHash
Returns a new instance of QueryHash.
13
14
15
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 13
def initialize(query)
@hash = query.nil? ? query : convert_to_hash_of_arrays(query)
end
|
Instance Method Details
#==(other) ⇒ Object
29
30
31
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 29
def ==(other)
QueryHash === other && other.query == query
end
|
#as_json(opts = {}) ⇒ Object
17
18
19
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 17
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.
35
36
37
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 35
def difference(other)
diff(query, symbolize_keys(CGI::parse(other.query)), allow_unexpected_keys: false)
end
|
#empty? ⇒ Boolean
47
48
49
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 47
def empty?
@hash && @hash.empty?
end
|
#eql?(other) ⇒ Boolean
25
26
27
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 25
def eql?(other)
self == other
end
|
#query ⇒ Object
39
40
41
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 39
def query
@hash
end
|
#to_json(opts = {}) ⇒ Object
21
22
23
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 21
def to_json(opts = {})
as_json(opts).to_json(opts)
end
|
#to_s ⇒ Object
43
44
45
|
# File 'lib/pact/consumer_contract/query_hash.rb', line 43
def to_s
@hash.inspect
end
|