From 1564c473a93105399bd777e78090463156948f2e Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Tue, 2 Oct 2012 18:52:34 -0700 Subject: Make ruby provider a better parent. In order to allow the provider to be a parent for other providers, I have implemented the following methods: section, setting, file_path, separator so that they can be overridden by child providers and decouple this provider from its type. --- lib/puppet/provider/ini_setting/ruby.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/ini_setting/ruby.rb b/lib/puppet/provider/ini_setting/ruby.rb index ba8165c..aca8ba2 100644 --- a/lib/puppet/provider/ini_setting/ruby.rb +++ b/lib/puppet/provider/ini_setting/ruby.rb @@ -6,15 +6,30 @@ Puppet::Type.type(:ini_setting).provide(:ruby) do end def create - ini_file.set_value(resource[:section], resource[:setting], resource[:value]) + ini_file.set_value(section, setting, resource[:value]) ini_file.save @ini_file = nil end + def section + resource[:section] + end + + def setting + resource[:setting] + end + + def file_path + resource[:path] + end + + def separator + resource[:key_val_separator] || '=' + end private def ini_file - @ini_file ||= Puppet::Util::IniFile.new(resource[:path], - resource[:key_val_separator]) + @ini_file ||= Puppet::Util::IniFile.new(file_path, separator) end + end -- cgit v1.2.3