Class: HalClient::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/hal_client/link.rb

Overview

HAL representation of a single link. Provides access to an embedded representation.

Direct Known Subclasses

MalformedLink, SimpleLink, TemplatedLink

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#curie_resolverObject (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_relObject (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_relObject



32
33
34
# File 'lib/hal_client/link.rb', line 32

def fully_qualified_rel
  curie_resolver.resolve(literal_rel)
end

#hashObject

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_hrefObject

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/hal_client/link.rb', line 14

def raw_href
  raise NotImplementedError
end

#target(vars = {}) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/hal_client/link.rb', line 22

def target(vars = {})
  raise NotImplementedError
end

#target_url(vars = {}) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/hal_client/link.rb', line 18

def target_url(vars = {})
  raise NotImplementedError
end

#templated?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/hal_client/link.rb', line 26

def templated?
  raise NotImplementedError
end