lib/sifttter_redux/configuration.rb in sifttter-redux-0.3.3 vs lib/sifttter_redux/configuration.rb in sifttter-redux-0.3.4

- old
+ new

@@ -16,10 +16,28 @@ # @return Hash # ---------------------------------------------------- def self.[](section_name) @data[section_name] end + + # ---------------------------------------------------- + # []= method + # + # Assigns the passed hash to the section. NOTE THAT THE + # PREVIOUS CONTENTS OF THAT SECTION ARE DELETED. + # @param section_name The section in which to look + # @param hash The Hash that gets merged into the section + # @return Void + # ---------------------------------------------------- + def self.[]=(section_name, hash) + if hash.is_a?(Hash) + @data[section_name] = {} + @data[section_name].merge!(hash) + else + fail ArgumentError, "Parameter is not a Hash: #{hash}" + end + end # ---------------------------------------------------- # add_section method # # Creates a new section in the configuration data. @@ -56,10 +74,20 @@ @data.delete(section_name) else CliMessage.warning("Can't delete non-existing section: #{section_name}") end end + + # ---------------------------------------------------- + # dump method + # + # Returns the data Hash + # @return Hash + # ---------------------------------------------------- + def self.dump + @data + end # ---------------------------------------------------- # load method # # Loads the configuration data (if it exists) and sets @@ -105,18 +133,8 @@ # @param section_name The section to look for # @return Bool # ---------------------------------------------------- def self.section_exists?(section_name) @data.key?(section_name) - end - - # ---------------------------------------------------- - # to_s method - # - # Method to output this Module as a String. - # @return Void - # ---------------------------------------------------- - def self.to_s - puts @data end end end