Class: HalClient::Interpreter

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hal_client/interpreter.rb

Overview

Interprets parsed JSON

Constant Summary collapse

RESERVED_PROPERTIES =
['_links', '_embedded'].freeze

Instance Method Summary collapse

Constructor Details

#initialize(parsed_json, hal_client) ⇒ Interpreter

Returns a new instance of Interpreter.



16
17
18
19
20
21
22
23
# File 'lib/hal_client/interpreter.rb', line 16

def initialize(parsed_json, hal_client)
  (fail InvalidRepresentationError,
        "Invalid HAL representation: #{parsed_json.inspect}") unless
    hashish?(parsed_json)

  @raw = parsed_json
  @hal_client = hal_client
end

Instance Method Details



30
31
32
# File 'lib/hal_client/interpreter.rb', line 30

def extract_links()
  extract_embedded_links +  extract_basic_links
end

#extract_propsObject

Returns hash of properties from ‘parsed_json`



26
27
28
# File 'lib/hal_client/interpreter.rb', line 26

def extract_props()
  raw.reject{|k,_| RESERVED_PROPERTIES.include?(k) }
end