Class: ShafClient::AlpsJson
- Inherits:
-
Resource
- Object
- BaseResource
- Resource
- ShafClient::AlpsJson
- Defined in:
- lib/shaf_client/alps_json.rb
Constant Summary
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 collapse
-
#descriptors ⇒ Object
readonly
Returns the value of attribute descriptors.
Attributes inherited from Resource
Attributes inherited from BaseResource
#attributes, #curies, #embedded_resources, #links
Instance Method Summary collapse
- #descriptor(id) ⇒ Object
- #each_descriptor(&block) ⇒ Object
-
#initialize(_client, payload, status = nil, headers = {}) ⇒ AlpsJson
constructor
A new instance of AlpsJson.
- #to_h ⇒ Object
Methods inherited from Resource
build, content_type, #content_type, default_resource_class!, #destroy!, #get, #get_doc, #get_hal_form, #inspect, profile, #reload!
Methods inherited from BaseResource
#[], #actions, #attribute, #curie, #embedded, #inspect, #link, #rel?, #to_s
Constructor Details
#initialize(_client, payload, status = nil, headers = {}) ⇒ AlpsJson
Returns a new instance of AlpsJson.
9 10 11 12 13 14 15 |
# File 'lib/shaf_client/alps_json.rb', line 9 def initialize(_client, payload, status = nil, headers = {}) super @links = {}.freeze @curies = {}.freeze @embedded_resources = {}.freeze end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ShafClient::BaseResource
Instance Attribute Details
#descriptors ⇒ Object (readonly)
Returns the value of attribute descriptors.
7 8 9 |
# File 'lib/shaf_client/alps_json.rb', line 7 def descriptors @descriptors end |
Instance Method Details
#descriptor(id) ⇒ Object
23 24 25 |
# File 'lib/shaf_client/alps_json.rb', line 23 def descriptor(id) descriptors.find { |desc| desc.id == id.to_sym } end |
#each_descriptor(&block) ⇒ Object
27 28 29 |
# File 'lib/shaf_client/alps_json.rb', line 27 def each_descriptor(&block) descriptors.each(&block) end |
#to_h ⇒ Object
17 18 19 20 21 |
# File 'lib/shaf_client/alps_json.rb', line 17 def to_h attributes.merge( descriptors: descriptors.map(&:to_h) ) end |