Class: JA2R::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/ja2r/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash, options = {}) ⇒ Parser

Returns a new instance of Parser.



3
4
5
6
7
# File 'lib/ja2r/parser.rb', line 3

def initialize(hash, options = {})
  @hash = hash
  @options = options
  @object_space = []
end

Instance Method Details

#callObject

Raises:



9
10
11
12
13
14
15
16
17
18
# File 'lib/ja2r/parser.rb', line 9

def call
  data = parse_data
  raise InvalidData.new('Hash does not appear to be valid json-api', @hash) unless data

  parse_included
  object_space.each do |object|
    assign_relationships object, object_map
  end
  data
end