Class: HyperResource::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/hyper_resource/adapter.rb,
lib/hyper_resource/adapter/hal_json.rb

Overview

HyperResource::Adapter is the interface/abstract base class for adapters to different hypermedia formats (e.g., HAL+JSON). New adapters must implement the public methods of this class.

Direct Known Subclasses

HAL_JSON

Defined Under Namespace

Classes: HAL_JSON

Class Method Summary collapse

Class Method Details

.apply(response, resource, opts = {}) ⇒ Object

Use a given deserialized response object (Hash) to update a given resource (HyperResource), returning the updated resource.

Raises:

  • (NotImplementedError)


24
25
26
27
# File 'lib/hyper_resource/adapter.rb', line 24

def apply(response, resource, opts={})
  raise NotImplementedError, "This is an abstract method -- subclasses "+
    "of HyperResource::Adapter must implement it."
end

.deserialize(string) ⇒ Object

Deserialize a given string into an object (Hash).

Raises:

  • (NotImplementedError)


17
18
19
20
# File 'lib/hyper_resource/adapter.rb', line 17

def deserialize(string)
  raise NotImplementedError, "This is an abstract method -- subclasses "+
    "of HyperResource::Adapter must implement it."
end

.serialize(object) ⇒ Object

Serialize the given object into a string.

Raises:

  • (NotImplementedError)


11
12
13
14
# File 'lib/hyper_resource/adapter.rb', line 11

def serialize(object)
  raise NotImplementedError, "This is an abstract method -- subclasses "+
    "of HyperResource::Adapter must implement it."
end