Sha256: 8ec1268133c2184cf07ae8a1476b95bf8a02f84536618f71e7b7906c21493bfa

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

# A reference to a resource.  Mostly just the type and title.
class Puppet::Parser::Resource::Reference
    include Puppet::Util::MethodHelper
    include Puppet::Util::Errors

    attr_accessor :type, :title, :builtin, :file, :line, :scope

    # Are we a builtin type?
    def builtin?
        unless defined? @builtin
            if builtintype()
                @builtin = true
            else
                @builtin = false
            end
        end

        self.builtin
    end

    def builtintype
        if t = Puppet::Type.type(self.type) and t.name != :component
            t
        else
            nil
        end
    end

    # Return the defined type for our obj.
    def definedtype
        unless defined? @definedtype
            if tmp = @scope.finddefine(self.type)
                @definedtype = tmp
            else
                fail Puppet::ParseError, "Could not find definition %s" % self.type
            end
        end

        @definedtype
    end

    def initialize(hash)
        set_options(hash)
        requiredopts(:type, :title)
    end

    def to_ref
        return [type.to_s,title.to_s]
    end

    def to_s
        unless defined? @namestring
            @namestring = "%s[%s]" % [type.capitalize, title]
        end
        @namestring
    end

    def typeclass
        unless defined? @typeclass
            if tmp = builtintype || definedtype
                @typeclass = tmp
            else
                fail Puppet::ParseError, "Could not find type %s" % self.type
            end
        end

        @typeclass
    end
end

# $Id: reference.rb 1967 2006-12-23 06:26:39Z luke $

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-0.22.4 lib/puppet/parser/resource/reference.rb
puppet-0.23.0 lib/puppet/parser/resource/reference.rb