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

Changeset 3190

Show
Ignore:
Timestamp:
11/24/05 20:26:01 (4 years ago)
Author:
bitsweat
Message:

Introduce Dependencies.warnings_on_first_load setting. If true, enables warnings on first load of a require_dependency. Otherwise, loads without warnings. Disabled (set to false) by default.

Files:

Legend:

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

    r3169 r3190  
    11*SVN* 
     2 
     3* Introduce Dependencies.warnings_on_first_load setting.  If true, enables warnings on first load of a require_dependency.  Otherwise, loads without warnings.  Disabled (set to false) by default.  [Jeremy Kemper] 
    24 
    35* Active Support is warnings-safe.  #1792 [Eric Hodel] 
  • trunk/activesupport/lib/active_support/dependencies.rb

    r3181 r3190  
    66module Dependencies #:nodoc: 
    77  extend self 
     8 
     9  # Should we turn on Ruby warnings on the first load of dependent files? 
     10  mattr_accessor :warnings_on_first_load 
     11  self.warnings_on_first_load = false 
    812 
    913  # All files ever loaded. 
     
    5155 
    5256      begin 
    53         # Enable warnings iff this file has not been loaded before. 
    54         if history.include?(file_name) 
     57        # Enable warnings iff this file has not been loaded before and 
     58        # warnings_on_first_load is set. 
     59        if !warnings_on_first_load or history.include?(file_name) 
    5560          load load_file_name 
    5661        else 
  • trunk/activesupport/test/dependencies_test.rb

    r3181 r3190  
    4747  def test_warnings_should_be_enabled_on_first_load 
    4848    old_mechanism, Dependencies.mechanism = Dependencies.mechanism, :load 
     49    old_warnings, Dependencies.warnings_on_first_load = Dependencies.warnings_on_first_load, true 
    4950 
    5051    filename = "#{File.dirname(__FILE__)}/dependencies/check_warnings" 
     
    7980  ensure 
    8081    Dependencies.mechanism = old_mechanism 
     82    Dependencies.warnings_on_first_load = old_warnings 
    8183  end 
    8284