Module: Dependencies

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

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



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

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

#clearObject



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

def clear
  self.loaded = [ ]
end

#depend_on(file_name, swallow_load_errors = false) ⇒ Object



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

def depend_on(file_name, swallow_load_errors = false)
  if !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)


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

def load?
  mechanism == :load
end

#remove_subclasses_for(*classes) ⇒ Object



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

def remove_subclasses_for(*classes)
  classes.each { |klass| klass.remove_subclasses }
end

#require_or_load(file_name) ⇒ Object



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

def require_or_load(file_name)
  file_name = "#{file_name}.rb" unless ! load? || /\.rb$/ =~ file_name
  load? ? load(file_name) : require(file_name)
end