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:



105
106
107
# File 'lib/configuration_service/test/response.rb', line 105

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



115
116
117
# File 'lib/configuration_service/test/response.rb', line 115

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

#dataObject

The configuration data dictionary of the response

Raises:

  • (NotImplementedError)

    always



143
144
145
# File 'lib/configuration_service/test/response.rb', line 143

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



125
126
127
# File 'lib/configuration_service/test/response.rb', line 125

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

#found?false

Whether the identified configuration was found

Returns:

  • (false)

    always



134
135
136
# File 'lib/configuration_service/test/response.rb', line 134

def found?
  false
end

#metadataObject

The configuration metadata’s revision

Raises:

  • (NotImplementedError)

    always



161
162
163
# File 'lib/configuration_service/test/response.rb', line 161

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

#revisionObject

The configuration metadata’s revision

Raises:

  • (NotImplementedError)

    always



152
153
154
# File 'lib/configuration_service/test/response.rb', line 152

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