Sha256: 20b3a938686051f8586145cad160b9e3159922312b7f60713d40330e695f026f

Contents?: true

Size: 921 Bytes

Versions: 6

Compression:

Stored size: 921 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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-0.24.0 lib/puppet/metatype/tags.rb
puppet-0.24.2 lib/puppet/metatype/tags.rb
puppet-0.24.4 lib/puppet/metatype/tags.rb
puppet-0.24.3 lib/puppet/metatype/tags.rb
puppet-0.24.1 lib/puppet/metatype/tags.rb
puppet-0.24.5 lib/puppet/metatype/tags.rb