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

Changeset 4769

Show
Ignore:
Timestamp:
08/16/06 09:18:17 (2 years ago)
Author:
bitsweat
Message:

Dependencies can autoload directories of nested classes.

Files:

Legend:

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

    r4760 r4769  
    11*SVN* 
     2 
     3* Dependencies can autoload directories of nested classes. [Jeremy Kemper] 
     4    Example: 
     5      invoice.rb            class Invoice 
     6      invoice/lineitem.rb   class Invoice::Lineitem 
    27 
    38* Add Deprecation.silence so that Reloadable does not scold itself. [Nicholas Seckar] 
  • trunk/activesupport/lib/active_support/dependencies.rb

    r4754 r4769  
    283283    else 
    284284      begin 
    285         parent.send :const_missing, class_id 
     285        begin 
     286          Dependencies.load_missing_constant self, class_id 
     287        rescue NameError 
     288          parent.send :const_missing, class_id 
     289        end 
    286290      rescue NameError => e 
    287291        # Make sure that the name we are missing is the one that caused the error 
  • trunk/activesupport/test/autoloading_fixtures/module_folder/nested_class.rb

    r4060 r4769  
    1 class ModuleFolder::NestedClass 
     1module ModuleFolder 
     2  class NestedClass 
     3  end 
    24end 
  • trunk/activesupport/test/dependencies_test.rb

    r4730 r4769  
    126126  end 
    127127 
    128   def test_directories_should_manifest_as_modules 
     128  def test_directories_manifest_as_modules_unless_const_defined 
    129129    with_loading 'autoloading_fixtures' do 
    130130      assert_kind_of Module, ModuleFolder 
     
    133133  end 
    134134 
    135   def test_nested_class_access 
     135  def test_module_with_nested_class 
    136136    with_loading 'autoloading_fixtures' do 
    137137      assert_kind_of Class, ModuleFolder::NestedClass 
    138138      Object.send :remove_const, :ModuleFolder 
     139    end 
     140  end 
     141 
     142  def test_module_with_nested_inline_class 
     143    with_loading 'autoloading_fixtures' do 
     144      assert_kind_of Class, ModuleFolder::InlineClass 
     145      Object.send :remove_const, :ModuleFolder 
     146    end 
     147  end 
     148 
     149  def test_directories_may_manifest_as_nested_classes 
     150    with_loading 'autoloading_fixtures' do 
     151      assert_kind_of Class, ClassFolder 
     152      Object.send :remove_const, :ClassFolder 
     153    end 
     154  end 
     155 
     156  def test_class_with_nested_class 
     157    with_loading 'autoloading_fixtures' do 
     158      assert_kind_of Class, ClassFolder::NestedClass 
     159      Object.send :remove_const, :ClassFolder 
     160    end 
     161  end 
     162 
     163  def test_class_with_nested_inline_class 
     164    with_loading 'autoloading_fixtures' do 
     165      assert_kind_of Class, ClassFolder::InlineClass 
     166      Object.send :remove_const, :ClassFolder 
    139167    end 
    140168  end