Module: Puppet::Interface::DocGen Private
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .strip_whitespace(text) ⇒ Object private
Instance Method Summary collapse
Class Method Details
.strip_whitespace(text) ⇒ 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.
9 10 11 12 |
# File 'lib/puppet/interface/documentation.rb', line 9 def self.strip_whitespace(text) # I don't want no... Puppet::Util::Docs.scrub(text) end |
Instance Method Details
#attr_doc(name, &validate) ⇒ 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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppet/interface/documentation.rb', line 23 def attr_doc(name, &validate) # Now, which form of the setter do we want, validated or not? get_arg = "value.to_s" if validate define_method(:"_validate_#{name}", validate) get_arg = "_validate_#{name}(#{get_arg})" end # We use module_eval, which I don't like much, because we can't have an # argument to a block with a default value in Ruby 1.8, and I don't like # the side-effects (eg: no argument count validation) of using blocks # without as methods. When we are 1.9 only (hah!) you can totally # replace this with some up-and-up define_method. --daniel 2011-04-29 module_eval(<<-EOT, __FILE__, __LINE__ + 1) def #{name}(value = nil) # def attribute(value=nil) self.#{name} = value unless value.nil? # self.attribute = value unless value.nil? @#{name} # @value end # end def #{name}=(value) # def attribute=(value) @#{name} = Puppet::Interface::DocGen.strip_whitespace(#{get_arg}) # @value = Puppet::Interface::DocGen.strip_whitespace(#{get_arg}) end # end EOT end |