This object defines a path from which Constants can be loaded.
Methods
Public Class methods
Create a new load path with the filesystem path
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 136
136: def initialize(root) @root = root end
Public Instance methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 154
154: def const_name_to_file_name(name)
155: name.to_s.underscore + '.rb'
156: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 158
158: def const_name_to_module_name(name)
159: name.to_s.underscore
160: end
Return nil if the path does not exist, or the path to a directory if the path leads to a module, or the path to a file if it leads to an object.
[ show source ]
# File vendor/rails/activesupport/lib/active_support/dependencies.rb, line 140
140: def filesystem_path(path, allow_module=true)
141: fs_path = [@root]
142: fs_path += path[0..-2].collect {|name| const_name_to_module_name name}
143:
144: if allow_module
145: result = File.join(fs_path, const_name_to_module_name(path.last))
146: return result if File.directory? result # Return the module path if one exists
147: end
148:
149: result = File.join(fs_path, const_name_to_file_name(path.last))
150:
151: return File.file?(result) ? result : nil
152: end