Class: ShafClient::ProblemJson

Inherits:
Resource show all
Includes:
StatusCodes
Defined in:
lib/shaf_client/problem_json.rb

Constant Summary

Constants included from StatusCodes

StatusCodes::StatusCode

Constants included from MimeTypes

MimeTypes::MIME_TYPE_ALPS_JSON, MimeTypes::MIME_TYPE_HAL, MimeTypes::MIME_TYPE_JSON, MimeTypes::MIME_TYPE_PROBLEM_JSON

Instance Attribute Summary

Attributes inherited from Resource

#headers, #http_status

Attributes inherited from BaseResource

#attributes, #curies, #embedded_resources, #links

Instance Method Summary collapse

Methods inherited from Resource

build, content_type, #content_type, default_resource_class!, #destroy!, #get, #get_doc, #get_hal_form, #initialize, #inspect, profile, #reload!

Methods inherited from BaseResource

#[], #actions, #attribute, #curie, #embedded, #initialize, #inspect, #link, #rel?, #to_s

Constructor Details

This class inherits a constructor from ShafClient::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ShafClient::BaseResource

Instance Method Details

#detailObject



26
27
28
# File 'lib/shaf_client/problem_json.rb', line 26

def detail
  attribute(:detail)
end

#instanceObject



30
31
32
# File 'lib/shaf_client/problem_json.rb', line 30

def instance
  attribute(:instance)
end

#statusObject



22
23
24
# File 'lib/shaf_client/problem_json.rb', line 22

def status
  attribute(:status) { http_status }
end

#titleObject



14
15
16
17
18
19
20
# File 'lib/shaf_client/problem_json.rb', line 14

def title
  attribute(:title) do
    next unless type == 'about:blank'

    StatusCode[status] if (400..599).include? status.to_i
  end
end

#to_hObject



34
35
36
# File 'lib/shaf_client/problem_json.rb', line 34

def to_h
  attributes
end

#typeObject



10
11
12
# File 'lib/shaf_client/problem_json.rb', line 10

def type
  attribute(:type) { 'about:blank' }
end