class Puppet::Pops::Issues::MessageData
Provides a binding of arguments passed to Issue.format to method names available in the issue's message producing block. @api private
Public Class Methods
# File lib/puppet/pops/issues.rb 63 def initialize *argnames 64 singleton = class << self; self end 65 argnames.each do |name| 66 singleton.send(:define_method, name) do 67 @data[name] 68 end 69 end 70 end
Public Instance Methods
# File lib/puppet/pops/issues.rb 72 def format(hash, &block) 73 @data = hash 74 instance_eval(&block) 75 end
Obtains the label provider given as a key `:label` in the hash passed to format. The label provider is return if no arguments are given. If given an argument, returns the result of calling label on the label provider.
@param args [Object] one object to obtain a label for or zero arguments to obtain the label provider @return [LabelProvider,String] the label provider or label depending on if an argument is given or not @raise [Puppet::Error] if no label provider is found
# File lib/puppet/pops/issues.rb 84 def label(*args) 85 args.empty? ? label_provider : label_provider.label(args[0]) 86 end
Returns the label provider given as key `:label` in the hash passed to format. @return [LabelProvider] the label provider @raise [Puppet::Error] if no label provider is found
# File lib/puppet/pops/issues.rb 91 def label_provider 92 label_provider = @data[:label] 93 #TRANSLATORS ":label" is a keyword and should not be translated 94 raise Puppet::Error, _('Label provider key :label must be set to produce the text of the message!') unless label_provider 95 label_provider 96 end
Returns the label provider given as a key in the hash passed to format.
# File lib/puppet/pops/issues.rb 100 def semantic 101 #TRANSLATORS ":semantic" is a keyword and should not be translated 102 raise Puppet::Error, _('Label provider key :semantic must be set to produce the text of the message!') unless @data[:semantic] 103 @data[:semantic] 104 end