diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2010-11-16 11:21:35 -0800 |
|---|---|---|
| committer | Matt Robinson <matt@puppetlabs.com> | 2010-11-16 14:12:14 -0800 |
| commit | c643e98c57e781353bfac55e7edb6690450076e3 (patch) | |
| tree | 6d673a436ebd59fd552ff3a74c999bd504790aa4 /lib/puppet/provider/mcx | |
| parent | 0d24ea3583c4cd6a4583f4788686a4f9e02cb994 (diff) | |
| download | puppet-c643e98c57e781353bfac55e7edb6690450076e3.tar.gz puppet-c643e98c57e781353bfac55e7edb6690450076e3.tar.xz puppet-c643e98c57e781353bfac55e7edb6690450076e3.zip | |
(#5079) Move methods around to make it clearer whether they're public or private
One method was showing up as a private class method, which turns out
isn't possible, so it got moved into the public section.
This is a rework for diff clarity of a patch submitted by
Sandor Szuecs <sandor.szuecs@fu-berlin.de>
Reviewed-by: Paul Berry <paul@puppetlabs.com>
Diffstat (limited to 'lib/puppet/provider/mcx')
| -rw-r--r-- | lib/puppet/provider/mcx/mcxcontent.rb | 99 |
1 files changed, 48 insertions, 51 deletions
diff --git a/lib/puppet/provider/mcx/mcxcontent.rb b/lib/puppet/provider/mcx/mcxcontent.rb index cb5adc698..b7cc40b87 100644 --- a/lib/puppet/provider/mcx/mcxcontent.rb +++ b/lib/puppet/provider/mcx/mcxcontent.rb @@ -82,10 +82,6 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do mcx_list end - private - - # mcxexport is used by instances, and therefore - # a class method. def self.mcxexport(ds_type, ds_name) ds_t = TypeMap[ds_type] ds_n = ds_name.to_s @@ -93,6 +89,54 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do dscl 'localhost', '-mcxexport', ds_path end + + def create + self.content=(resource[:content]) + end + + def destroy + ds_parms = get_dsparams + ds_t = TypeMap[ds_parms[:ds_type]] + ds_n = ds_parms[:ds_name].to_s + ds_path = "/Local/Default/#{ds_t}/#{ds_n}" + + dscl 'localhost', '-mcxdelete', ds_path + end + + def exists? + # JJM Just re-use the content method and see if it's empty. + begin + mcx = content + rescue Puppet::ExecutionFailure => e + return false + end + has_mcx = ! mcx.empty? + end + + def content + ds_parms = get_dsparams + + mcx = self.class.mcxexport( + ds_parms[:ds_type], + + ds_parms[:ds_name]) + mcx + end + + def content=(value) + # dscl localhost -mcximport + ds_parms = get_dsparams + + mcx = mcximport( + ds_parms[:ds_type], + ds_parms[:ds_name], + + resource[:content]) + mcx + end + + private + def mcximport(ds_type, ds_name, val) ds_t = TypeMap[ds_type] ds_n = ds_name.to_s @@ -155,51 +199,4 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do end - public - - def create - self.content=(resource[:content]) - end - - def destroy - ds_parms = get_dsparams - ds_t = TypeMap[ds_parms[:ds_type]] - ds_n = ds_parms[:ds_name].to_s - ds_path = "/Local/Default/#{ds_t}/#{ds_n}" - - dscl 'localhost', '-mcxdelete', ds_path - end - - def exists? - # JJM Just re-use the content method and see if it's empty. - begin - mcx = content - rescue Puppet::ExecutionFailure => e - return false - end - has_mcx = ! mcx.empty? - end - - def content - ds_parms = get_dsparams - - mcx = self.class.mcxexport( - ds_parms[:ds_type], - - ds_parms[:ds_name]) - mcx - end - - def content=(value) - # dscl localhost -mcximport - ds_parms = get_dsparams - - mcx = mcximport( - ds_parms[:ds_type], - ds_parms[:ds_name], - - resource[:content]) - mcx - end - end |
