Browse Source

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.
Dan Bode 11 years ago
parent
commit
1564c47
1 changed files with 18 additions and 3 deletions
  1. 18 3
      lib/puppet/provider/ini_setting/ruby.rb

+ 18 - 3
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