Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3124

Show
Ignore:
Timestamp:
11/21/05 07:06:33 (3 years ago)
Author:
bitsweat
Message:

Turn warnings on when loading a file if Dependencies.mechanism == :load. Common mistakes such as redefined methods will print warnings to stderr. References #752. References #1792.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r3119 r3124  
    11*SVN* 
     2 
     3* Turn warnings on when loading a file if Dependencies.mechanism == :load.  Common mistakes such as redefined methods will print warnings to stderr.  [Jeremy Kemper] 
    24 
    35* Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.] 
  • trunk/activesupport/lib/active_support/dependencies.rb

    r2976 r3124  
    3434    self.loaded = [ ] 
    3535  end 
    36    
     36 
    3737  def require_or_load(file_name) 
    3838    file_name = "#{file_name}.rb" unless ! load? || file_name[-3..-1] == '.rb' 
    39     load? ? load(file_name) : require(file_name) 
    40   end 
    41    
     39    if load? 
     40      begin 
     41        original_verbosity, $VERBOSE = $VERBOSE, true 
     42        load file_name 
     43      ensure 
     44        $VERBOSE = original_verbosity 
     45      end 
     46    else 
     47      require file_name 
     48    end 
     49  end 
     50 
    4251  def remove_subclasses_for(*classes) 
    4352    Object.remove_subclasses_of(*classes)