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


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

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

#clearObject


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

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
27
28
# 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
    rescue Object => e
      raise ScriptError, "#{e.message}"
    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


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

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

#require_or_load(file_name) ⇒ Object


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

def require_or_load(file_name)
  load? ? load("#{file_name}.rb") : require(file_name)
end