Class: Jahuty::Resource::Problem
- Inherits:
-
Object
- Object
- Jahuty::Resource::Problem
- Defined in:
- lib/jahuty/resource/problem.rb
Overview
An application/problem+json response. The API should respond with a problem whenever a client- or server-error occurs.
Instance Attribute Summary collapse
-
#detail ⇒ Object
Returns the value of attribute detail.
-
#status ⇒ Object
Returns the value of attribute status.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status:, type:, detail:) ⇒ Problem
constructor
A new instance of Problem.
Constructor Details
#initialize(status:, type:, detail:) ⇒ Problem
Returns a new instance of Problem.
10 11 12 13 14 |
# File 'lib/jahuty/resource/problem.rb', line 10 def initialize(status:, type:, detail:) @status = status @type = type @detail = detail end |
Instance Attribute Details
#detail ⇒ Object
Returns the value of attribute detail.
8 9 10 |
# File 'lib/jahuty/resource/problem.rb', line 8 def detail @detail end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/jahuty/resource/problem.rb', line 8 def status @status end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/jahuty/resource/problem.rb', line 8 def type @type end |
Class Method Details
.from(data) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/jahuty/resource/problem.rb', line 16 def self.from(data) raise ArgumentError.new, 'Key :status missing' unless data.key?(:status) raise ArgumentError.new, 'Key :type missing' unless data.key?(:type) raise ArgumentError.new, 'Key :detail missing' unless data.key?(:detail) Problem.new(**data.slice(:status, :type, :detail)) end |