Class: Excon::HyperMedia::LinkObject

Inherits:
Object
  • Object
show all
Includes:
Collection
Defined in:
lib/excon/hypermedia/link_object.rb

Overview

Link

Encapsulates a link pointing to a resource.

Instance Method Summary collapse

Methods included from Collection

#[], #each, #initialize, #key?, #keys

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Excon::HyperMedia::Collection

Instance Method Details

#deprecationObject

deprecation

The “deprecation” property is OPTIONAL.

Its presence indicates that the link is to be deprecated (i.e. removed) at a future date. Its value is a URL that SHOULD provide further information about the deprecation.

A client SHOULD provide some notification (for example, by logging a warning message) whenever it traverses over a link that has this property. The notification SHOULD include the deprecation property’s value so that a client manitainer can easily find information about the deprecation.



72
73
74
# File 'lib/excon/hypermedia/link_object.rb', line 72

def deprecation
  to_property!(__method__)
end

#hrefObject

href

The “href” property is REQUIRED.

Its value is either a URI [RFC3986] or a URI Template [RFC6570].

If the value is a URI Template then the Link Object SHOULD have a “templated” attribute whose value is true.



25
26
27
# File 'lib/excon/hypermedia/link_object.rb', line 25

def href
  to_property!(:href)
end

#hreflangObject

hreflang

The “hreflang” property is OPTIONAL.

Its value is a string and is intended for indicating the language of the target resource (as defined by [RFC5988]).



124
125
126
# File 'lib/excon/hypermedia/link_object.rb', line 124

def hreflang
  to_property!(__method__)
end

#nameObject

name

The “name” property is OPTIONAL.

Its value MAY be used as a secondary key for selecting Link Objects which share the same relation type.



85
86
87
# File 'lib/excon/hypermedia/link_object.rb', line 85

def name
  to_property!(__method__)
end

#profileObject

profile

The “profile” property is OPTIONAL.

Its value is a string which is a URI that hints about the profile (as defined by [I-D.wilde-profile-link]) of the target resource.



98
99
100
# File 'lib/excon/hypermedia/link_object.rb', line 98

def profile
  to_property!(__method__)
end

#rel(params = {}) ⇒ Excon::Connection

rel

Returns an ‘Excon::Connection` instance, based on the current link.

Returns:

  • (Excon::Connection)

    Connection object based on current link



144
145
146
# File 'lib/excon/hypermedia/link_object.rb', line 144

def rel(params = {})
  Excon.new(href, params)
end

#templatedObject

The “templated” property is OPTIONAL.

Its value is boolean and SHOULD be true when the Link Object’s “href” property is a URI Template.

Its value SHOULD be considered false if it is undefined or any other value than true.

@see: tools.ietf.org/html/draft-kelly-json-hal-08#section-5.2



39
40
41
# File 'lib/excon/hypermedia/link_object.rb', line 39

def templated
  to_property(__method__) || false
end

#titleObject

title

The “title” property is OPTIONAL.

Its value is a string and is intended for labelling the link with a human-readable identifier (as defined by [RFC5988]).



111
112
113
# File 'lib/excon/hypermedia/link_object.rb', line 111

def title
  to_property!(__method__)
end

#typeObject

type

The “type” property is OPTIONAL.

Its value is a string used as a hint to indicate the media type expected when dereferencing the target resource.

@see: tools.ietf.org/html/draft-kelly-json-hal-08#section-5.3



52
53
54
# File 'lib/excon/hypermedia/link_object.rb', line 52

def type
  to_property!(__method__)
end

#uriURI

uri

Returns a URI representation of the provided “href” property.

Returns:

  • (URI)

    URI object of the “href” property



134
135
136
# File 'lib/excon/hypermedia/link_object.rb', line 134

def uri
  ::Addressable::URI.parse(href)
end