Class: PactBroker::Api::Decorators::CustomErrorProblemJsonDecorator
- Inherits:
-
Object
- Object
- PactBroker::Api::Decorators::CustomErrorProblemJsonDecorator
- Defined in:
- lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb
Instance Method Summary collapse
-
#initialize(title:, type:, detail:, status:) ⇒ CustomErrorProblemJsonDecorator
constructor
A new instance of CustomErrorProblemJsonDecorator.
- #to_hash(user_options: {}, **__other) ⇒ Hash
-
#to_json(*args, **kwargs) ⇒ String
JSON.
Constructor Details
#initialize(title:, type:, detail:, status:) ⇒ CustomErrorProblemJsonDecorator
Returns a new instance of CustomErrorProblemJsonDecorator.
12 13 14 15 16 17 |
# File 'lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb', line 12 def initialize(title:, type:, detail:, status: ) @title = title @type = type @detail = detail @status = status end |
Instance Method Details
#to_hash(user_options: {}, **__other) ⇒ Hash
20 21 22 23 24 25 26 27 |
# File 'lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb', line 20 def to_hash(user_options: {}, **__other) { "title" => @title, "type" => "#{[:base_url]}/problem/#{@type}", "detail" => @detail, "status" => @status } end |
#to_json(*args, **kwargs) ⇒ String
Returns JSON.
30 31 32 |
# File 'lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb', line 30 def to_json(*args, **kwargs) to_hash(*args, **kwargs).to_json end |