Class: HalClient

Inherits:
Object
  • Object
show all
Defined in:
lib/hal_client.rb,
lib/hal_client/version.rb,
lib/hal_client/representation.rb,
lib/hal_client/representation_set.rb

Overview

Adapter used to access resources.

Defined Under Namespace

Classes: Representation, RepresentationSet

Constant Summary collapse

VERSION =
"1.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HalClient

Initializes a new client instance

options - hash of configuration options :accept - one or more content types that should be prepended to the Accept header field of each request.



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

def initialize(options={})
  @default_accept = options.fetch(:accept, 'application/hal+json')
end

Instance Method Details

#get(url, options = {}) ⇒ Object

Returns a Representation of the resource identified by url.

url - The URL of the resource of interest. options - set of options to pass to RestClient#get



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

def get(url, options={})
  resp = RestClient.get url, rest_client_options(options)
  Representation.new self, MultiJson.load(resp)
end