# File lib/has_many_polymorphs/autoload.rb, line 31
  def self.setup

    _logger_debug "autoload hook invoked"

    options[:requirements].each do |requirement|
      _logger_warn "forcing requirement load of #{requirement}"
      require requirement
    end

    Dir.glob(options[:file_pattern]).each do |filename|
      next if filename =~ /#{options[:file_exclusions].join("|")}/
      open(filename) do |file|
        if file.grep(/#{options[:methods].join("|")}/).any?
          begin
            # determines the modelname by the directory - this allows the autoload of namespaced models
            modelname = filename[0..-4].gsub("#{MODELS_ROOT.to_s}/", "")
            model = modelname.camelize
            _logger_warn "preloading parent model #{model}"
            model.constantize
          rescue Object => e
            _logger_warn "#{model} could not be preloaded: #{e.inspect} #{e.backtrace}"
          end
        end
      end
    end
  end