Module: Puppet::Util::ClassGen
- Includes:
- Puppet::Util, MethodHelper
- Included in:
- MetaType::Manager, Network::XMLRPCClient, Reports, Type, FileType, Log
- Defined in:
- lib/puppet/util/classgen.rb
Instance Method Summary collapse
-
#genclass(name, options = {}, &block) ⇒ Object
Create a new subclass.
-
#genmodule(name, options = {}, &block) ⇒ Object
Create a new module.
-
#rmclass(name, options) ⇒ Object
Remove an existing class.
Methods included from Puppet::Util
activerecord_version, benchmark, chuser, classproxy, #execfail, #execpipe, execute, logmethods, memory, proxy, recmkdir, secure_open, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, which, withumask
Methods included from POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from MethodHelper
#requiredopts, #set_options, #symbolize_options
Instance Method Details
#genclass(name, options = {}, &block) ⇒ Object
Create a new subclass. Valid options are:
-
:array: An array of existing classes. If specified, the new class is added to this array. -
:attributes: A hash of attributes to set before the block is evaluated. -
:block: The block to evaluate in the context of the class. You can also just pass the block normally, but it will still be evaluated withclass_eval. -
:constant: What to set the constant as. Defaults to the capitalized name. -
:hash: A hash of existing classes. If specified, the new class is added to this hash, and it is also used for overwrite tests. -
:overwrite: Whether to overwrite an existing class. -
:parent: The parent class for the generated class. Defaults to self. -
:prefix: The constant prefix. Default to nothing; if specified, the capitalized name is appended and the result is set as the constant.
27 28 29 |
# File 'lib/puppet/util/classgen.rb', line 27 def genclass(name, = {}, &block) genthing(name, Class, , block) end |
#genmodule(name, options = {}, &block) ⇒ Object
Create a new module. Valid options are:
-
:array: An array of existing classes. If specified, the new class is added to this array. -
:attributes: A hash of attributes to set before the block is evaluated. -
:block: The block to evaluate in the context of the class. You can also just pass the block normally, but it will still be evaluated withclass_eval. -
:constant: What to set the constant as. Defaults to the capitalized name. -
:hash: A hash of existing classes. If specified, the new class is added to this hash, and it is also used for overwrite tests. -
:overwrite: Whether to overwrite an existing class. -
:prefix: The constant prefix. Default to nothing; if specified, the capitalized name is appended and the result is set as the constant.
46 47 48 |
# File 'lib/puppet/util/classgen.rb', line 46 def genmodule(name, = {}, &block) genthing(name, Module, , block) end |
#rmclass(name, options) ⇒ Object
Remove an existing class
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/puppet/util/classgen.rb', line 51 def rmclass(name, ) = () const = genconst_string(name, ) retval = false if const_defined?(const) remove_const(const) retval = true end if hash = [:hash] and hash.include? name hash.delete(name) retval = true end # Let them know whether we did actually delete a subclass. retval end |