Class: Hyperclient::Discoverer::URLExtractor Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperclient/discoverer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Extract the url from a HAL representation.

Instance Method Summary collapse

Constructor Details

#initialize(representation) ⇒ URLExtractor

Initializes a URLExtractor.

Parameters:

  • representation

    A Hash with the representation of a Resource.



67
68
69
# File 'lib/hyperclient/discoverer.rb', line 67

def initialize(representation)
  @representation = representation
end

Instance Method Details

#urlObject

Returns a String with the resource URL



72
73
74
75
76
77
78
79
# File 'lib/hyperclient/discoverer.rb', line 72

def url
  return @representation.delete('href') if @representation.include?('href')

  if @representation && @representation['_links'] && @representation['_links']['self'] &&
    (url = @representation['_links']['self']['href'])
    return url
  end
end