Class: Proforma::Modeling::Collection
- Inherits:
-
Object
- Object
- Proforma::Modeling::Collection
- 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
- #compile(data, evaluator) ⇒ Object
-
#initialize(children: []) ⇒ Collection
constructor
A new instance of Collection.
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
#children ⇒ Object
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 |