Class: ConfigurationService::Test::Response::Failure

Inherits:
Object
  • Object
show all
Defined in:
lib/configuration_service/test/response.rb

Overview

Encapsulates a configuration service error

This allows a OrchestrationProvider to decouple the Orchestrator from the semantics of the configuration service’s error handling.

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ Failure

Returns a new instance of Failure.

Parameters:



103
104
105
# File 'lib/configuration_service/test/response.rb', line 103

def initialize(exception)
  @exception = exception
end

Instance Method Details

#allowed?true, false

Whether the request was allowed

Returns:

  • (true)

    if the request was allowed

  • (false)

    if the request was a not allowed



113
114
115
# File 'lib/configuration_service/test/response.rb', line 113

def allowed?
  !@exception.is_a?(ConfigurationService::AuthorizationError)
end

#dataObject

The configuration data dictionary of the response

Raises:

  • (NotImplementedError)

    always



141
142
143
# File 'lib/configuration_service/test/response.rb', line 141

def data
  raise NotImplementedError, "configuration not available after #{@exception.inspect}"
end

#failed?true, false

Whether the request was authorized but failed

Returns:

  • (true)

    if the request was allowed but raised a Error

  • (false)

    if the request was not allowed or raised an unexpected error



123
124
125
# File 'lib/configuration_service/test/response.rb', line 123

def failed?
  allowed? and @exception.is_a?(ConfigurationService::Error)
end

#found?false

Whether the identified configuration was found

Returns:

  • (false)

    always



132
133
134
# File 'lib/configuration_service/test/response.rb', line 132

def found?
  false
end

#metadataObject

The configuration metadata’s revision

Raises:

  • (NotImplementedError)

    always



159
160
161
# File 'lib/configuration_service/test/response.rb', line 159

def 
  raise NotImplementedError, "metadata not available after #{@exception.inspect}"
end

#revisionObject

The configuration metadata’s revision

Raises:

  • (NotImplementedError)

    always



150
151
152
# File 'lib/configuration_service/test/response.rb', line 150

def revision
  raise NotImplementedError, "revision not available after #{@exception.inspect}"
end