Class: Dependencies::RootLoadingModule

Inherits:
LoadingModule show all
Defined in:
lib/active_support/dependencies.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LoadingModule

#const_available?, #const_load!, #const_missing, root

Methods inherited from Module

#mattr_accessor, #mattr_reader, #mattr_writer

Constructor Details

#initialize(*paths) ⇒ RootLoadingModule

Returns a new instance of RootLoadingModule.



102
103
104
# File 'lib/active_support/dependencies.rb', line 102

def initialize(*paths)
  @load_paths = paths.flatten.collect {|p| p.kind_of?(ConstantLoadPath) ? p : ConstantLoadPath.new(p)}
end

Instance Attribute Details

#load_pathsObject (readonly)

Returns the value of attribute load_paths.



100
101
102
# File 'lib/active_support/dependencies.rb', line 100

def load_paths
  @load_paths
end

Instance Method Details

#clear!Object

Erase all items in this module



120
121
122
123
124
125
# File 'lib/active_support/dependencies.rb', line 120

def clear!
  constants.each do |name|
    Object.send(:remove_const, name) if Object.const_defined?(name) && self.path.empty?
    self.send(:remove_const, name)
  end
end

#load_file!(file_path) ⇒ Object

Load the source file at the given file path



111
112
113
114
115
116
117
# File 'lib/active_support/dependencies.rb', line 111

def load_file!(file_path)
  begin root.module_eval(IO.read(file_path), file_path, 1)
  rescue Object => exception
    exception.blame_file! file_path
    raise
  end
end

#pathObject



108
# File 'lib/active_support/dependencies.rb', line 108

def path() [] end

#rootObject



106
# File 'lib/active_support/dependencies.rb', line 106

def root() self end