class SirenClient::Link

Attributes

config[R]
href[RW]
payload[R]
rels[R]
title[R]
type[R]

Public Class Methods

new(data, config={}) click to toggle source
# File lib/siren_client/link.rb, line 8
def initialize(data, config={})
  super()
  if data.class != Hash
    raise ArgumentError, "You must pass in a Hash to SirenClient::Link.new"
  end
  @payload = data
  @config = { format: :json }.merge config

  @rels  = @payload['rel']   || []
  @href  = @payload['href']  || ''
  @title = @payload['title'] || ''
  @type  = @payload['type']  || ''
end

Public Instance Methods

go() click to toggle source
# File lib/siren_client/link.rb, line 22
def go
  if next_response_is_raw?
    disable_raw_response
    generate_raw_response(:get, self.href, @config)
  else
    Entity.new(self.href, @config)
  end
end