Class: Puppet::Pops::Issues::MessageData Private
- Defined in:
- lib/puppet/pops/issues.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides a binding of arguments passed to Issue.format to method names available in the issue’s message producing block.
Instance Method Summary collapse
- #format(hash, &block) ⇒ Object private
-
#initialize(*argnames) ⇒ MessageData
constructor
private
A new instance of MessageData.
-
#label(it = nil) ⇒ Object
private
Returns the label provider given as a key in the hash passed to #format.
-
#semantic ⇒ Object
private
Returns the label provider given as a key in the hash passed to #format.
Constructor Details
#initialize(*argnames) ⇒ MessageData
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MessageData.
62 63 64 65 66 67 68 69 |
# File 'lib/puppet/pops/issues.rb', line 62 def initialize *argnames singleton = class << self; self end argnames.each do |name| singleton.send(:define_method, name) do @data[name] end end end |
Instance Method Details
#format(hash, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 |
# File 'lib/puppet/pops/issues.rb', line 71 def format(hash, &block) @data = hash instance_eval &block end |
#label(it = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the label provider given as a key in the hash passed to #format. If given an argument, calls #label on the label provider (caller would otherwise have to call label.label(it)
80 81 82 83 |
# File 'lib/puppet/pops/issues.rb', line 80 def label(it = nil) raise "Label provider key :label must be set to produce the text of the message!" unless @data[:label] it.nil? ? @data[:label] : @data[:label].label(it) end |
#semantic ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the label provider given as a key in the hash passed to #format.
87 88 89 90 |
# File 'lib/puppet/pops/issues.rb', line 87 def semantic raise "Label provider key :semantic must be set to produce the text of the message!" unless @data[:semantic] @data[:semantic] end |