Class: HalClient

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

Overview

Adapter used to access resources.

Defined Under Namespace

Modules: EntryPointCovenienceMethods Classes: CurieResolver, Representation, RepresentationSet

Constant Summary collapse

VERSION =
"1.5.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.



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

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



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

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