Module: XcodeResultBundleProcessor::SLF0::Deserializer

Includes:
Methadone::CLILogging
Defined in:
lib/xcoderesultbundleprocessor/slf0/deserializer.rb

Class Method Summary collapse

Class Method Details

.deserialize(tokens) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xcoderesultbundleprocessor/slf0/deserializer.rb', line 6

def self.deserialize(tokens)
  debug "Deserializing #{tokens.ai}"

  if tokens.first.nil?
    tokens.shift
    return nil
  end

  self._assert_first_token_type(ClassNameResolver::ResolvedClassName, tokens)

  resolved_class = tokens.shift
  return nil if resolved_class.nil?

  class_name = resolved_class.class_name
  raise "Unsupported class #{class_name}" unless Model.const_defined?(class_name)

  Model.const_get(class_name).deserialize(tokens)
end

.deserialize_list(tokens) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/xcoderesultbundleprocessor/slf0/deserializer.rb', line 25

def self.deserialize_list(tokens)
  if tokens.first.nil?
    tokens.shift
    return []
  end

  self._assert_first_token_type(Tokenizer::ObjectList, tokens)

  object_list_info = tokens.shift

  object_list_info.mystery_number.times.map { Deserializer.deserialize(tokens) }
end