Class: Committee::Drivers::HyperSchema::Link
- Inherits:
-
Object
- Object
- Committee::Drivers::HyperSchema::Link
- Defined in:
- lib/committee/drivers/hyper_schema/link.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.
12 13 14 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 12 def initialize(hyper_schema_link) @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.
17 18 19 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 17 def enc_type hyper_schema_link.enc_type end |
#href ⇒ Object
21 22 23 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 21 def href hyper_schema_link.href end |
#media_type ⇒ Object
The link’s output media type. i.e. How responses should be encoded.
26 27 28 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 26 def media_type hyper_schema_link.media_type end |
#method ⇒ Object
30 31 32 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 30 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.
38 39 40 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 38 def parent hyper_schema_link.parent end |
#rel ⇒ Object
42 43 44 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 42 def rel hyper_schema_link.rel end |
#schema ⇒ Object
The link’s input schema. i.e. How we validate an endpoint’s incoming parameters.
48 49 50 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 48 def schema hyper_schema_link.schema end |
#status_success ⇒ Object
52 53 54 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 52 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.
58 59 60 |
# File 'lib/committee/drivers/hyper_schema/link.rb', line 58 def target_schema hyper_schema_link.target_schema end |