Class: Mxrb::Compiler::ArtifactDocumentCompiler

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

Overview

Compiles Runtime roots whose executable representation is independent of UI bundles.

Constant Summary collapse

NAME_ONLY_TYPES =
%w[
  CustomIcons$CustomIconCollection Forms$Layout Forms$Snippet Menus$MenuDocument
].freeze
TYPES =
(NAME_ONLY_TYPES + %w[
  Enumerations$Enumeration Images$ImageCollection RegularExpressions$RegularExpression
  ScheduledEvents$ScheduledEvent DomainModels$ViewEntitySourceDocument
]).freeze

Instance Method Summary collapse

Instance Method Details

#compile(unit) ⇒ Object

rubocop:disable Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mxrb/compiler/artifact_document_compiler.rb', line 17

def compile(unit) # rubocop:disable Metrics/AbcSize
  source = unit.document
  return named(source, unit.module_name) if NAME_ONLY_TYPES.include?(source['$Type'])

  case source['$Type']
  when 'Enumerations$Enumeration' then enumeration(source, unit.module_name)
  when 'Images$ImageCollection' then image_collection(source, unit.module_name)
  when 'RegularExpressions$RegularExpression' then regular_expression(source, unit.module_name)
  when 'ScheduledEvents$ScheduledEvent' then scheduled_event(source, unit.module_name)
  when 'DomainModels$ViewEntitySourceDocument' then named(source, unit.module_name)
  else raise CompilationError, "unsupported Runtime artifact #{source['$Type']}"
  end
end