Sha256: 60aaaf731b72bc1ea3a35a14124b364a01354ecf02d1a0da3ea482497e29b6b2

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

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

    def parent=(parent)
        if self.parentof?(parent)
            devfail "%s[%s] is already the parent of %s[%s]" %
                [self.class.name, self.title, parent.class.name, parent.title]
        end
        @parent = parent
    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
        self.class.delete(self)

        @parent = nil

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

# $Id: container.rb 2499 2007-05-09 21:30:44Z luke $

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-0.23.0 lib/puppet/metatype/container.rb
puppet-0.23.1 lib/puppet/metatype/container.rb
puppet-0.23.2 lib/puppet/metatype/container.rb