Class: Pact::QueryString

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

Instance Method Summary collapse

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.



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

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

Instance Method Details

#==(other) ⇒ Object



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

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

#as_json(opts = {}) ⇒ Object



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

def as_json opts = {}
  @query
end

#difference(other) ⇒ Object



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

def difference(other)
  require 'pact/matchers' # avoid recursive loop between this file and pact/matchers
  Pact::Matchers.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)


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

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



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

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