# File lib/puppet/resource/type.rb, line 106
106:   def merge(other)
107:     fail "#{name} is not a class; cannot add code to it" unless type == :hostclass
108:     fail "#{other.name} is not a class; cannot add code from it" unless other.type == :hostclass
109:     fail "Cannot have code outside of a class/node/define because 'freeze_main' is enabled" if name == "" and Puppet.settings[:freeze_main]
110: 
111:     if parent and other.parent and parent != other.parent
112:       fail "Cannot merge classes with different parent classes (#{name} => #{parent} vs. #{other.name} => #{other.parent})"
113:     end
114: 
115:     # We know they're either equal or only one is set, so keep whichever parent is specified.
116:     self.parent ||= other.parent
117: 
118:     if other.doc
119:       self.doc ||= ""
120:       self.doc += other.doc
121:     end
122: 
123:     # This might just be an empty, stub class.
124:     return unless other.code
125: 
126:     unless self.code
127:       self.code = other.code
128:       return
129:     end
130: 
131:     array_class = Puppet::Parser::AST::ASTArray
132:     self.code = array_class.new(:children => [self.code]) unless self.code.is_a?(array_class)
133: 
134:     if other.code.is_a?(array_class)
135:       code.children += other.code.children
136:     else
137:       code.children << other.code
138:     end
139:   end