Class: HalClient::Interpreter
- Inherits:
-
Object
- Object
- HalClient::Interpreter
- Extended by:
- Forwardable
- Defined in:
- lib/hal_client/interpreter.rb
Overview
Interprets parsed JSON
Constant Summary collapse
- RESERVED_PROPERTIES =
Collection of reserved properties tools.ietf.org/html/draft-kelly-json-hal-07#section-4.1
['_links', '_embedded'].freeze
Instance Method Summary collapse
- #extract_links ⇒ Object
-
#extract_props ⇒ Object
Returns hash of properties from ‘parsed_json`.
-
#initialize(parsed_json, hal_client) ⇒ Interpreter
constructor
A new instance of Interpreter.
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
#extract_links ⇒ Object
30 31 32 |
# File 'lib/hal_client/interpreter.rb', line 30 def extract_links() + extract_basic_links end |
#extract_props ⇒ Object
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 |