Sha256: 4007885b7c63e2706fccc924cdb27da6dc0f96265e3e89bffa8f30b471f91512

Contents?: true

Size: 969 Bytes

Versions: 4

Compression:

Stored size: 969 Bytes

Contents

class Puppet::Type
    attr_reader :tags

    # Add a new tag.
    def tag(tag)
        tag = tag.intern if tag.is_a? String
        unless @tags.include? tag
            @tags << tag
        end
    end

    # Define the initial list of tags.
    def tags=(list)
        list = [list] unless list.is_a? Array

        @tags = list.collect do |t|
            case t
            when String: t.intern
            when Symbol: t
            else
                self.warning "Ignoring tag %s of type %s" % [tag.inspect, tag.class]
            end
        end

        @tags << self.class.name unless @tags.include?(self.class.name)
    end

    # Figure out of any of the specified tags apply to this object.  This is an
    # OR operation.
    def tagged?(tags)
        tags = [tags] unless tags.is_a? Array

        tags = tags.collect { |t| t.intern }

        return tags.find { |tag| @tags.include? tag }
    end
end

# $Id: tags.rb 1762 2006-10-10 20:59:10Z luke $

Version data entries

4 entries across 4 versions & 1 rubygems

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