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

new(*argnames) click to toggle source
   # File lib/puppet/pops/issues.rb
62 def initialize *argnames
63   singleton = class << self; self end
64   argnames.each do |name|
65     singleton.send(:define_method, name) do
66       @data[name]
67     end
68   end
69 end

Public Instance Methods

format(hash, &block) click to toggle source
   # File lib/puppet/pops/issues.rb
71 def format(hash, &block)
72   @data = hash
73   instance_eval(&block)
74 end
label(*args) click to toggle source

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
83 def label(*args)
84   args.empty? ? label_provider : label_provider.label(args[0])
85 end
label_provider() click to toggle source

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
90 def label_provider
91   label_provider = @data[:label]
92   #TRANSLATORS ":label" is a keyword and should not be translated
93   raise Puppet::Error, _('Label provider key :label must be set to produce the text of the message!') unless label_provider
94   label_provider
95 end
semantic() click to toggle source

Returns the label provider given as a key in the hash passed to format.

    # File lib/puppet/pops/issues.rb
 99 def semantic
100   #TRANSLATORS ":semantic" is a keyword and should not be translated
101   raise Puppet::Error, _('Label provider key :semantic must be set to produce the text of the message!') unless @data[:semantic]
102   @data[:semantic]
103 end