Class: Halchemy::Follower

Inherits:
Object
  • Object
show all
Defined in:
lib/halchemy/follower.rb

Overview

Provides the way to navigate from a resource by following to a link relation

Instance Method Summary collapse

Constructor Details

#initialize(api, resource) ⇒ Follower

Returns a new instance of Follower.



6
7
8
9
# File 'lib/halchemy/follower.rb', line 6

def initialize(api, resource)
  @api = api
  @resource = resource
end

Instance Method Details

#to(rel) ⇒ Object

Parameters:

  • rel (String)


12
13
14
15
16
17
18
# File 'lib/halchemy/follower.rb', line 12

def to(rel)
  unless @resource["_links"].key?(rel)
    raise KeyError, "#{@resource.class} does not have a link relation named #{rel}"
  end

  Requester.new(@api, [@resource, rel])
end