Module: Dependencies

Extended by:
Dependencies
Included in:
Dependencies
Defined in:
lib/active_support/dependencies.rb

Overview

:nodoc:

Defined Under Namespace

Classes: ConstantLoadPath, LoadingModule, RootLoadingModule

Constant Summary collapse

@@loaded =
[ ]
@@mechanism =
:load

Instance Method Summary collapse

Instance Method Details

#associate_with(file_name) ⇒ Object



29
30
31
# File 'lib/active_support/dependencies.rb', line 29

def associate_with(file_name)
  depend_on(file_name, true)
end

#clearObject



33
34
35
# File 'lib/active_support/dependencies.rb', line 33

def clear
  self.loaded = [ ]
end

#depend_on(file_name, swallow_load_errors = false) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_support/dependencies.rb', line 17

def depend_on(file_name, swallow_load_errors = false)
  unless loaded.include?(file_name)
    loaded << file_name

    begin
      require_or_load(file_name)
    rescue LoadError
      raise unless swallow_load_errors
    end
  end
end

#load?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/active_support/dependencies.rb', line 13

def load?
  mechanism == :load
end

#remove_subclasses_for(*classes) ⇒ Object



42
43
44
# File 'lib/active_support/dependencies.rb', line 42

def remove_subclasses_for(*classes)
  Object.remove_subclasses_of(*classes)
end

#require_or_load(file_name) ⇒ Object



37
38
39
40
# File 'lib/active_support/dependencies.rb', line 37

def require_or_load(file_name)
  file_name = "#{file_name}.rb" unless ! load? || file_name[-3..-1] == '.rb'
  load? ? load(file_name) : require(file_name)
end