summaryrefslogtreecommitdiffstats
path: root/lib/puppet/metatype/container.rb
blob: dbc8a3dee8c77ec2b215e4e58846a40b3477dfb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class Puppet::Type

    # this is a retarded hack method to get around the difference between
    # component children and file children
    def self.depthfirst?
        if defined? @depthfirst
            return @depthfirst
        else
            return false
        end
    end
    
    def depthfirst?
        self.class.depthfirst?
    end

    # Add a hook for testing for recursion.
    def parentof?(child)
        if (self == child)
            debug "parent is equal to child"
            return true
        elsif defined? @parent and @parent.parentof?(child)
            debug "My parent is parent of child"
            return true
        else
            return false
        end
    end

    # Remove an object.  The argument determines whether the object's
    # subscriptions get eliminated, too.
    def remove(rmdeps = true)
        # This is hackish (mmm, cut and paste), but it works for now, and it's
        # better than warnings.
        @parameters.each do |name, obj|
            obj.remove
        end
        @parameters.clear

        @parent = nil

        # Remove the reference to the provider.
        if self.provider
            @provider.clear
            @provider = nil
        end
    end
end