Class: PactBroker::Client::Hal::ErrorEntity

Inherits:
Entity
  • Object
show all
Defined in:
lib/pact_broker/client/hal/entity.rb

Instance Method Summary collapse

Methods inherited from Entity

#_link, #_link!, #_links, #_links!, #can?, #embedded_entities, #embedded_entity, #fetch, #follow, #get, #method_missing, #patch, #post, #put, #respond_to_missing?, #response

Constructor Details

#initialize(href, data, http_client, response = nil) ⇒ ErrorEntity

Returns a new instance of ErrorEntity.



129
130
131
132
133
134
135
# File 'lib/pact_broker/client/hal/entity.rb', line 129

def initialize(href, data, http_client, response = nil)
  @href = href
  @data = data
  @links = {}
  @client = http_client
  @response = response
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PactBroker::Client::Hal::Entity

Instance Method Details

#assert_success!(messages = {}) ⇒ Object



145
146
147
148
149
150
151
152
153
# File 'lib/pact_broker/client/hal/entity.rb', line 145

def assert_success!(messages = {})
  default_message = "Error retrieving #{@href} status=#{response ? response.status: nil} #{response ? response.raw_body : ''}".strip
  message = if response && messages[response.status]
    (messages[response.status] || "") + " (#{default_message})"
  else
    default_message
  end
  raise ErrorResponseReturned.new(message)
end

#does_not_exist?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/pact_broker/client/hal/entity.rb', line 137

def does_not_exist?
  response && response.status == 404
end

#success?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/pact_broker/client/hal/entity.rb', line 141

def success?
  false
end