Class: Leadlight::Link

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

Direct Known Subclasses

LinkTemplate

Constant Summary collapse

HTTP_METHODS =
[
  :options, :head, :get, :get_representation!, :post, :put, :delete, :patch
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, href, rel = nil, title = rel, options = {}) ⇒ Link

Returns a new instance of Link.



14
15
16
17
18
19
20
21
# File 'lib/leadlight/link.rb', line 14

def initialize(service, href, rel=nil, title=rel, options={})
  @service = service
  @href    = Addressable::URI.parse(href)
  @rel     = rel.to_s
  @title   = title.to_s
  @rev     = options[:rev]
  @aliases = Array(options[:aliases])
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



12
13
14
# File 'lib/leadlight/link.rb', line 12

def aliases
  @aliases
end

#hrefObject (readonly)

Returns the value of attribute href.



11
12
13
# File 'lib/leadlight/link.rb', line 11

def href
  @href
end

#relObject (readonly)

Returns the value of attribute rel.



8
9
10
# File 'lib/leadlight/link.rb', line 8

def rel
  @rel
end

#revObject (readonly)

Returns the value of attribute rev.



9
10
11
# File 'lib/leadlight/link.rb', line 9

def rev
  @rev
end

#serviceObject (readonly)

Returns the value of attribute service.



7
8
9
# File 'lib/leadlight/link.rb', line 7

def service
  @service
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/leadlight/link.rb', line 10

def title
  @title
end

Instance Method Details

#follow(*args) ⇒ Object



29
30
31
32
33
# File 'lib/leadlight/link.rb', line 29

def follow(*args)
  get_representation!(*args) do |representation|
    return representation
  end
end