Class: Mxrb::Compiler::SettingsDocumentCompiler

Inherits:
Object
  • Object
show all
Includes:
ModelValues
Defined in:
lib/mxrb/compiler/settings_document_compiler.rb

Overview

Compiles project settings using the ordered, version-matched Runtime schema.

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ SettingsDocumentCompiler

Returns a new instance of SettingsDocumentCompiler.



9
10
11
# File 'lib/mxrb/compiler/settings_document_compiler.rb', line 9

def initialize(schema)
  @schema = schema
end

Instance Method Details

#compile(unit) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mxrb/compiler/settings_document_compiler.rb', line 13

def compile(unit)
  source = unit.document
  unless source['$Type'] == 'Settings$ProjectSettings'
    raise CompilationError,
          "unsupported settings root #{source['$Type']}"
  end

  {
    '$ID' => source['$ID'], '$Type' => source['$Type'],
    'Settings' => array(source['Settings']).map { compile_node(_1) }
  }
end