~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb

  • Committer: Michael Forrest
  • Date: 2010-10-15 16:28:50 UTC
  • Revision ID: michael.forrest@canonical.com-20101015162850-tj2vchanv0kr0dun
refrozeĀ gems

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
class Module
 
2
  # Returns String#underscore applied to the module name minus trailing classes.
 
3
  #
 
4
  #   ActiveRecord.as_load_path               # => "active_record"
 
5
  #   ActiveRecord::Associations.as_load_path # => "active_record/associations"
 
6
  #   ActiveRecord::Base.as_load_path         # => "active_record" (Base is a class)
 
7
  #
 
8
  # The Kernel module gives an empty string by definition.
 
9
  #
 
10
  #   Kernel.as_load_path # => ""
 
11
  #   Math.as_load_path   # => "math"
 
12
  def as_load_path
 
13
    if self == Object || self == Kernel
 
14
      ''
 
15
    elsif is_a? Class
 
16
      parent == self ? '' : parent.as_load_path
 
17
    else
 
18
      name.split('::').collect do |word|
 
19
        word.underscore
 
20
      end * '/'
 
21
    end
 
22
  end
 
23
end
 
 
b'\\ No newline at end of file'