Class: Committee::Drivers::HyperSchema::Link
- Inherits:
-
Object
- Object
- Committee::Drivers::HyperSchema::Link
- Defined in:
- lib/committee/drivers/hyper_schema.rb
Overview
Link abstracts an API link specifically for JSON hyper-schema.
For most operations, it’s a simple pass through to a JsonSchema::Schema::Link, but implements some exotic behavior in a few places.
Instance Method Summary collapse
-
#enc_type ⇒ Object
The link’s input media type.
- #href ⇒ Object
-
#initialize(hyper_schema_link) ⇒ Link
constructor
A new instance of Link.
-
#media_type ⇒ Object
The link’s output media type.
- #method ⇒ Object
-
#parent ⇒ Object
Passes through a link’s parent resource.
- #rel ⇒ Object
-
#schema ⇒ Object
The link’s input schema.
- #status_success ⇒ Object
-
#target_schema ⇒ Object
The link’s output schema.
Constructor Details
#initialize(hyper_schema_link) ⇒ Link
Returns a new instance of Link.
68 69 70 |
# File 'lib/committee/drivers/hyper_schema.rb', line 68 def initialize(hyper_schema_link) self.hyper_schema_link = hyper_schema_link end |
Instance Method Details
#enc_type ⇒ Object
The link’s input media type. i.e. How requests should be encoded.
73 74 75 |
# File 'lib/committee/drivers/hyper_schema.rb', line 73 def enc_type hyper_schema_link.enc_type end |
#href ⇒ Object
77 78 79 |
# File 'lib/committee/drivers/hyper_schema.rb', line 77 def href hyper_schema_link.href end |
#media_type ⇒ Object
The link’s output media type. i.e. How responses should be encoded.
82 83 84 |
# File 'lib/committee/drivers/hyper_schema.rb', line 82 def media_type hyper_schema_link.media_type end |
#method ⇒ Object
86 87 88 |
# File 'lib/committee/drivers/hyper_schema.rb', line 86 def method hyper_schema_link.method end |
#parent ⇒ Object
Passes through a link’s parent resource. Note that this is not part of the Link interface and is here to support a legacy Heroku-ism behavior that allowed a link tagged with rel=instances to imply that a list will be returned.
94 95 96 |
# File 'lib/committee/drivers/hyper_schema.rb', line 94 def parent hyper_schema_link.parent end |
#rel ⇒ Object
98 99 100 |
# File 'lib/committee/drivers/hyper_schema.rb', line 98 def rel hyper_schema_link.rel end |
#schema ⇒ Object
The link’s input schema. i.e. How we validate an endpoint’s incoming parameters.
104 105 106 |
# File 'lib/committee/drivers/hyper_schema.rb', line 104 def schema hyper_schema_link.schema end |
#status_success ⇒ Object
108 109 110 |
# File 'lib/committee/drivers/hyper_schema.rb', line 108 def status_success hyper_schema_link.rel == "create" ? 201 : 200 end |
#target_schema ⇒ Object
The link’s output schema. i.e. How we validate an endpoint’s response data.
114 115 116 |
# File 'lib/committee/drivers/hyper_schema.rb', line 114 def target_schema hyper_schema_link.target_schema end |