class DTK::Puppet::ParseStructure::TopPS

Public Class Methods

new(ast_array = nil, opts = {}) click to toggle source
Calls superclass method
# File lib/dtk_puppet/parse_structure.rb, line 97
def initialize(ast_array = nil, opts = {})
  self[:children] = []
  add_children(ast_array, opts)
  super
end

Public Instance Methods

add_children(ast_array, opts = {}) click to toggle source
# File lib/dtk_puppet/parse_structure.rb, line 103
def add_children(ast_array, opts = {})
  return unless ast_array

  ast_array.instantiate('').each do |ast_item|
    ast_item_type = ast_item.type
    child =
      if TPS.include?(ast_item_type)
        ComponentPS.create(ast_item, opts)
      else
        fail DTK::Client::Error.new("Unexpected top level ast type (#{ast_item.class})")
      end
    self[:children] << child if child
  end
end