Class: Proforma::Modeling::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/proforma/modeling/collection.rb

Overview

A general purpose grouping of modeling objects. When compiled, they will each be compiled once then their output(s) are combined and flattened.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(children: []) ⇒ Collection

Returns a new instance of Collection.



19
20
21
# File 'lib/proforma/modeling/collection.rb', line 19

def initialize(children: [])
  @children = ModelFactory.array(children)
end

Instance Attribute Details

#childrenObject



23
24
25
# File 'lib/proforma/modeling/collection.rb', line 23

def children
  Array(@children)
end

Instance Method Details

#compile(data, evaluator) ⇒ Object



27
28
29
30
31
# File 'lib/proforma/modeling/collection.rb', line 27

def compile(data, evaluator)
  children.map do |section|
    section.respond_to?(:compile) ? section.compile(data, evaluator) : section
  end.flatten
end