Sha256: a8a5f60bc5f1fd6df648362665f832fee6f67d0b783dfbbcfd42cb68848a529a

Contents?: true

Size: 834 Bytes

Versions: 4

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

#
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

module Proforma
  module Modeling
    # A general purpose grouping of modeling objects.  When compiled, they will each be
    # compiled once then their output(s) are combined and flattened.
    class Collection
      acts_as_hashable

      attr_writer :children

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

      def children
        Array(@children)
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
proforma-1.0.2 lib/proforma/modeling/collection.rb
proforma-1.0.1 lib/proforma/modeling/collection.rb
proforma-1.0.0 lib/proforma/modeling/collection.rb
proforma-1.0.0.pre.alpha lib/proforma/modeling/collection.rb