Class: HalClient::Link
- Inherits:
-
Object
- Object
- HalClient::Link
- Defined in:
- lib/hal_client/link.rb
Overview
HAL representation of a single link. Provides access to an embedded representation.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#curie_resolver ⇒ Object
readonly
Returns the value of attribute curie_resolver.
-
#literal_rel ⇒ Object
readonly
Returns the value of attribute literal_rel.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Links with the same href, same rel value, and the same ‘templated’ value are considered equal.
- #fully_qualified_rel ⇒ Object
-
#hash ⇒ Object
Differing Representations or Addressable::Templates with matching hrefs will get matching hash values, since we are using raw_href and not the objects themselves when computing hash.
- #raw_href ⇒ Object
- #target(vars = {}) ⇒ Object
- #target_url(vars = {}) ⇒ Object
- #templated? ⇒ Boolean
Instance Attribute Details
#curie_resolver ⇒ Object (readonly)
Returns the value of attribute curie_resolver.
30 31 32 |
# File 'lib/hal_client/link.rb', line 30 def curie_resolver @curie_resolver end |
#literal_rel ⇒ Object (readonly)
Returns the value of attribute literal_rel.
30 31 32 |
# File 'lib/hal_client/link.rb', line 30 def literal_rel @literal_rel end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Links with the same href, same rel value, and the same ‘templated’ value are considered equal. Otherwise, they are considered unequal. Links without a href (for example anonymous embedded links, are never equal to one another.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hal_client/link.rb', line 40 def ==(other) return false if raw_href.nil? return false unless other.respond_to?(:raw_href) && other.respond_to?(:fully_qualified_rel) && other.respond_to?(:templated?) (raw_href == other.raw_href) && (fully_qualified_rel == other.fully_qualified_rel) && (templated? == other.templated?) end |
#fully_qualified_rel ⇒ Object
32 33 34 |
# File 'lib/hal_client/link.rb', line 32 def fully_qualified_rel curie_resolver.resolve(literal_rel) end |
#hash ⇒ Object
Differing Representations or Addressable::Templates with matching hrefs will get matching hash values, since we are using raw_href and not the objects themselves when computing hash
57 58 59 60 61 |
# File 'lib/hal_client/link.rb', line 57 def hash [fully_qualified_rel, raw_href, templated?].hash end |
#raw_href ⇒ Object
14 15 16 |
# File 'lib/hal_client/link.rb', line 14 def raw_href raise NotImplementedError end |
#target(vars = {}) ⇒ Object
22 23 24 |
# File 'lib/hal_client/link.rb', line 22 def target(vars = {}) raise NotImplementedError end |
#target_url(vars = {}) ⇒ Object
18 19 20 |
# File 'lib/hal_client/link.rb', line 18 def target_url(vars = {}) raise NotImplementedError end |
#templated? ⇒ Boolean
26 27 28 |
# File 'lib/hal_client/link.rb', line 26 def templated? raise NotImplementedError end |