def load_config_files(name, force=false)
      name = name.to_s

      # Return last config file hash list loaded,
      # if reload is disabled and files have already been loaded.
      return self.cache_config_files[name] if self.reload_disabled? && self.cache_config_files[name]

      logger.info "Loading config files for: #{name}"
      logger.debug "load_config_files(#{name.inspect})"

      # Get current time for checking last loaded status.
      now = Time.now

      # Get array of all the existing files file the config name.
      config_files = self.get_config_files(name)

      # Get all the data from all yaml files into as configs
      configs = config_files.collect do |f|
        name, name_with_suffix, filename, ext, modified_time = * f

        # Get the cached file info the specific file, if
        # it's been loaded before.
        config_data, last_modified, last_loaded = self.cache[filename]

        logger.debug "f = #{f.inspect}\n" +
          "cache #{name_with_suffix} filename      = #{filename.inspect}\n" +
          "cache #{name_with_suffix} config_data   = #{config_data.inspect}\n" +
          "cache #{name_with_suffix} last_modified = #{last_modified.inspect}\n" +
          "cache #{name_with_suffix} last_loaded   = #{last_loaded.inspect}\n"

        # Load the file if its never been loaded or its been more than
        # so many minutes since last load attempt. (default: 5 minutes)
        if config_data.blank? || (now - last_loaded > self.reload_interval)
          if force || config_data.blank? || modified_time != last_modified

            logger.debug "modified_time #{name.inspect} #{filename.inspect} " +
              "changed #{modified_time != last_modified} : #{modified_time.inspect} #{last_modified.inspect}"

            logger.debug "RConfig: loading #{filename.inspect}"

            config_data = read(filename, name, ext)  # Get contents from config file

            logger.debug "RConfig: loaded #{filename.inspect} => #{config_data.inspect}"

            (self.config_loaded ||= {})[name] = config_files  # add files to the loaded files cache

            self.cache[filename] = [config_data, modified_time, now]  # Save cached config file contents, and modified_time.

            logger.debug "cache[#{filename.inspect}] = #{self.cache[filename].inspect}"

            self.cache_hash[name] = nil # Flush merged hash cache.

            self.cache_files[name] = config_files  # Config files changed or disappeared.

          end # if config_data == nil || (now - last_loaded > self.reload_interval)
        end # if force || config_data == nil || modified_time != last_modified

        config_data
      end # config_files.collect
      configs.compact!

      logger.debug "load_config_files(#{name.inspect}) => #{configs.inspect}"

      # Keep last loaded config files around in case self.reload_dsabled.
      self.cache_config_files[name] = configs #unless configs.empty?

      configs
    end
def load_config_files(name, force=false)
      name = name.to_s

      # Return last config file hash list loaded,
      # if reload is disabled and files have already been loaded.
      return self.cache_config_files[name] if self.reload_disabled? && self.cache_config_files[name]

      logger.info "Loading config files for: #{name}"
      logger.debug "load_config_files(#{name.inspect})"

      # Get current time for checking last loaded status.
      now = Time.now

      # Get array of all the existing files file the config name.
      config_files = self.get_config_files(name)

      # Get all the data from all yaml files into as configs
      configs = config_files.collect do |f|
        name, name_with_suffix, filename, ext, modified_time = * f

        # Get the cached file info the specific file, if
        # it's been loaded before.
        config_data, last_modified, last_loaded = self.cache[filename]

        logger.debug "f = #{f.inspect}\n" +
          "cache #{name_with_suffix} filename      = #{filename.inspect}\n" +
          "cache #{name_with_suffix} config_data   = #{config_data.inspect}\n" +
          "cache #{name_with_suffix} last_modified = #{last_modified.inspect}\n" +
          "cache #{name_with_suffix} last_loaded   = #{last_loaded.inspect}\n"

        # Load the file if its never been loaded or its been more than
        # so many minutes since last load attempt. (default: 5 minutes)
        if config_data.blank? || (now - last_loaded > self.reload_interval)
          if force || config_data.blank? || modified_time != last_modified

            logger.debug "modified_time #{name.inspect} #{filename.inspect} " +
              "changed #{modified_time != last_modified} : #{modified_time.inspect} #{last_modified.inspect}"

            logger.debug "RConfig: loading #{filename.inspect}"

            config_data = read(filename, name, ext)  # Get contents from config file

            logger.debug "RConfig: loaded #{filename.inspect} => #{config_data.inspect}"

            (self.config_loaded ||= {})[name] = config_files  # add files to the loaded files cache

            self.cache[filename] = [config_data, modified_time, now]  # Save cached config file contents, and modified_time.

            logger.debug "cache[#{filename.inspect}] = #{self.cache[filename].inspect}"

            self.cache_hash[name] = nil # Flush merged hash cache.

            self.cache_files[name] = config_files  # Config files changed or disappeared.

          end # if config_data == nil || (now - last_loaded > self.reload_interval)
        end # if force || config_data == nil || modified_time != last_modified

        config_data
      end # config_files.collect
      configs.compact!

      logger.debug "load_config_files(#{name.inspect}) => #{configs.inspect}"

      # Keep last loaded config files around in case self.reload_dsabled.
      self.cache_config_files[name] = configs #unless configs.empty?

      configs
    end
Get each config file's yaml hash for the given config name,
 to be merged later. Files will only be loaded if they have
 not been loaded before or the files have changed within the
 last five minutes, or force is explicitly set to true.