Class: PactBroker::Api::Decorators::RuntimeErrorProblemJsonDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/api/decorators/runtime_error_problem_json_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ RuntimeErrorProblemJsonDecorator

Returns a new instance of RuntimeErrorProblemJsonDecorator.

Parameters:

  • message (String)


9
10
11
# File 'lib/pact_broker/api/decorators/runtime_error_problem_json_decorator.rb', line 9

def initialize(message)
  @message = message
end

Instance Method Details

#to_hash(user_options:) ⇒ Hash

Returns:

  • (Hash)


14
15
16
17
18
19
20
21
# File 'lib/pact_broker/api/decorators/runtime_error_problem_json_decorator.rb', line 14

def to_hash(user_options:, **)
  {
    "title" => "Server error",
    "type" => "#{user_options[:base_url]}/problems/server-error",
    "detail" => message,
    "status" => 500
  }
end

#to_json(*args, **kwargs) ⇒ String

Returns JSON.

Returns:

  • (String)

    JSON



24
25
26
# File 'lib/pact_broker/api/decorators/runtime_error_problem_json_decorator.rb', line 24

def to_json(*args, **kwargs)
  to_hash(*args, **kwargs).to_json
end