Module: Puppet::Util::Tagging
- Included in:
- Parser::Resource, Resource, Resource::Catalog, Resource::Status, Transaction, Transaction::Event, Type, Log
- Defined in:
- lib/puppet/util/tagging.rb
Overview
A common module to handle tagging.
Instance Method Summary collapse
-
#tag(*ary) ⇒ Object
Add a tag to our current list.
-
#tagged?(*tags) ⇒ Boolean
Are we tagged with the provided tag?.
-
#tags ⇒ Object
Return a copy of the tag list, so someone can’t ask for our tags and then modify them.
- #tags=(tags) ⇒ Object
Instance Method Details
#tag(*ary) ⇒ Object
Add a tag to our current list. These tags will be added to all of the objects contained in this scope.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/puppet/util/tagging.rb', line 8 def tag(*ary) ||= [] qualified = [] ary.collect { |tag| tag.to_s.downcase }.each do |tag| fail(Puppet::ParseError, "Invalid tag #{tag.inspect}") unless valid_tag?(tag) qualified << tag if tag.include?("::") << tag unless .include?(tag) end ( qualified ) end |
#tagged?(*tags) ⇒ Boolean
Are we tagged with the provided tag?
23 24 25 |
# File 'lib/puppet/util/tagging.rb', line 23 def tagged?(*) not ( self. & .flatten.collect { |t| t.to_s } ).empty? end |
#tags ⇒ Object
Return a copy of the tag list, so someone can’t ask for our tags and then modify them.
29 30 31 32 |
# File 'lib/puppet/util/tagging.rb', line 29 def ||= [] .dup end |
#tags=(tags) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/puppet/util/tagging.rb', line 34 def () = [] return if .nil? or == "" = .strip.split(/\s*,\s*/) if .is_a?(String) .each do |t| tag(t) end end |