Class: MODL::Parser::ClassProcessor

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

Overview

This class handles the conversion of objects that refer to classes into instances of those classes. It works recursively since class usage can be nested.

Constant Summary collapse

MAX_RECURSION_DEPTH =

How deep can the class structure be?

50

Class Method Summary collapse

Class Method Details

.process(global, obj) ⇒ Object

global is a GlobalParseContext and obj is the extracted Array or Hash from MODL::Parser::Parsed.extract_json

Raises:

  • (StandardError)


33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/modl/parser/class_processor.rb', line 33

def self.process(global, obj)
  # Process each object in the array or just process the object if its a hash.
  # Any other object is ignored.
  raise StandardError, 'parameter "global" should be a GlobalParseContext' unless global.is_a?(GlobalParseContext)

  if obj.is_a? Array
    obj.each do |o|
      process_obj global, o if o.is_a? Hash
    end
  elsif obj.is_a? Hash
    process_obj global, obj
  end
end