module Puppet::Interface::DocGen
@api private
Public Class Methods
strip_whitespace(text)
click to toggle source
@api private
# File lib/puppet/interface/documentation.rb 7 def self.strip_whitespace(text) 8 # I don't want no... 9 Puppet::Util::Docs.scrub(text) 10 end
Public Instance Methods
attr_doc(name, &validate)
click to toggle source
@api private
# File lib/puppet/interface/documentation.rb 21 def attr_doc(name, &validate) 22 # Now, which form of the setter do we want, validated or not? 23 get_arg = "value.to_s" 24 if validate 25 define_method(:"_validate_#{name}", validate) 26 get_arg = "_validate_#{name}(#{get_arg})" 27 end 28 29 # We use module_eval, which I don't like much, because we can't have an 30 # argument to a block with a default value in Ruby 1.8, and I don't like 31 # the side-effects (eg: no argument count validation) of using blocks 32 # without as methods. When we are 1.9 only (hah!) you can totally 33 # replace this with some up-and-up define_method. --daniel 2011-04-29 34 module_eval(<<-EOT, __FILE__, __LINE__ + 1) 35 def #{name}(value = nil) 36 self.#{name} = value unless value.nil? 37 @#{name} 38 end 39 40 def #{name}=(value) 41 @#{name} = Puppet::Interface::DocGen.strip_whitespace(#{get_arg}) 42 end 43 EOT 44 end