Class: Pact::Hal::HttpClient::Response

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/pact/hal/http_client.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



101
102
103
104
105
106
107
108
# File 'lib/pact/hal/http_client.rb', line 101

def body
  bod = raw_body
  if bod && bod != ''
    JSON.parse(bod)
  else
    nil
  end
end

#json?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/pact/hal/http_client.rb', line 122

def json?
  self['content-type'] && self['content-type'] =~ /json/
end

#raw_bodyObject



110
111
112
# File 'lib/pact/hal/http_client.rb', line 110

def raw_body
  __getobj__().body
end

#statusObject



114
115
116
# File 'lib/pact/hal/http_client.rb', line 114

def status
  code.to_i
end

#success?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/pact/hal/http_client.rb', line 118

def success?
  __getobj__().code.start_with?("2")
end