Skip to content
This repository
Browse code

Improve documentation for add_lib_to_load_paths!

  • Loading branch information...
commit 9e081caee74e6d08035a8835899dcc566536a871 1 parent 5522578
José Valim authored June 20, 2010

Showing 1 changed file with 16 additions and 3 deletions. Show diff stats Hide diff stats

  1. 19  railties/lib/rails/application.rb
19  railties/lib/rails/application.rb
@@ -84,17 +84,30 @@ def method_missing(*args, &block)
84 84
 
85 85
     delegate :middleware, :to => :config
86 86
 
87  
-    def add_lib_to_load_paths!
  87
+    # This method is called just after an application inherits from Rails::Application,
  88
+    # allowing the developer to load classes in lib and use them during application
  89
+    # configuration.
  90
+    #
  91
+    #   class MyApplication < Rails::Application
  92
+    #     require "my_backend" # in lib/my_backend
  93
+    #     config.i18n.backend = MyBackend
  94
+    #   end
  95
+    #
  96
+    # Notice this method takes into consideration the default root path. So if you
  97
+    # are changing config.root inside your application definition or having a custom
  98
+    # Rails application, you will need to add lib to $LOAD_PATH on your own in case
  99
+    # you need to load files in lib/ during the application configuration as well.
  100
+    def add_lib_to_load_paths! #:nodoc:
88 101
       path = config.root.join('lib').to_s
89 102
       $LOAD_PATH.unshift(path) if File.exists?(path)
90 103
     end
91 104
 
92  
-    def require_environment!
  105
+    def require_environment! #:nodoc:
93 106
       environment = paths.config.environment.to_a.first
94 107
       require environment if environment
95 108
     end
96 109
 
97  
-    def eager_load!
  110
+    def eager_load! #:nodoc:
98 111
       railties.all(&:eager_load!)
99 112
       super
100 113
     end

0 notes on commit 9e081ca

Please sign in to comment.
Something went wrong with that request. Please try again.