Class: Pact::QueryString

Inherits:
Object
  • Object
show all
Includes:
ActiveSupportSupport, Matchers
Defined in:
lib/pact/consumer_contract/query_string.rb

Constant Summary

Constants included from Matchers

Matchers::DEFAULT_OPTIONS, Matchers::NO_DIFF, Matchers::NO_DIFF_AT_INDEX

Instance Method Summary collapse

Methods included from Matchers

#diff, #type_diff

Methods included from ActiveSupportSupport

#fix_all_the_things, #fix_json_formatting, #fix_regexp, #remove_unicode

Constructor Details

#initialize(query) ⇒ QueryString

Returns a new instance of QueryString.



9
10
11
# File 'lib/pact/consumer_contract/query_string.rb', line 9

def initialize query
  @query = query.nil? ? query : query.dup
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
# File 'lib/pact/consumer_contract/query_string.rb', line 25

def == other
  QueryString === other && other.query == query
end

#as_json(opts = {}) ⇒ Object



13
14
15
# File 'lib/pact/consumer_contract/query_string.rb', line 13

def as_json opts = {}
  @query
end

#difference(other) ⇒ Object



29
30
31
# File 'lib/pact/consumer_contract/query_string.rb', line 29

def difference(other)
  diff(query, other.query)
end

#empty?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/pact/consumer_contract/query_string.rb', line 41

def empty?
  @query && @query.empty?
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/pact/consumer_contract/query_string.rb', line 21

def eql? other
  self == other
end

#nil?Boolean

Naughty…

Returns:

  • (Boolean)


46
47
48
# File 'lib/pact/consumer_contract/query_string.rb', line 46

def nil?
  @query.nil?
end

#queryObject



33
34
35
# File 'lib/pact/consumer_contract/query_string.rb', line 33

def query
  @query
end

#to_json(opts = {}) ⇒ Object



17
18
19
# File 'lib/pact/consumer_contract/query_string.rb', line 17

def to_json opts = {}
  as_json(opts).to_json(opts)
end

#to_sObject



37
38
39
# File 'lib/pact/consumer_contract/query_string.rb', line 37

def to_s
  @query
end