Class: Object

Inherits:
BasicObject
Defined in:
lib/action_controller/test_process.rb,
lib/action_view/vendor/builder/blankslate.rb,
lib/action_controller/support/dependencies.rb,
lib/action_controller/support/core_ext/object_and_class.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.blank_slate_method_addedObject



46
# File 'lib/action_view/vendor/builder/blankslate.rb', line 46

alias_method :blank_slate_method_added, :method_added

.const_missing(class_id) ⇒ Object

Use const_missing to autoload associations so we don’t have to require_association when using single-table inheritance.



54
55
56
57
58
59
60
61
# File 'lib/action_controller/support/dependencies.rb', line 54

def const_missing(class_id)
  begin
    require_or_load(class_id.to_s.demodulize.underscore)
    if Object.const_defined?(class_id) then return Object.const_get(class_id) else raise LoadError end
  rescue LoadError
    raise NameError, "uninitialized constant #{class_id}"
  end
end

.method_added(name) ⇒ Object



47
48
49
50
51
# File 'lib/action_view/vendor/builder/blankslate.rb', line 47

def method_added(name)
  blank_slate_method_added(name)
  return  if self != Object
  Builder::BlankSlate.hide(name)
end

Instance Method Details

#remove_subclasses_of(superclass) ⇒ Object



2
3
4
# File 'lib/action_controller/support/core_ext/object_and_class.rb', line 2

def remove_subclasses_of(superclass)
  subclasses_of(superclass).each { |subclass| Object.send(:remove_const, subclass) rescue nil }
end

#require(file_name) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/action_controller/test_process.rb', line 8

def require(file_name)
  begin
    require_without_load_path_reloading(file_name)
  rescue Object => e
    ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
    require_without_load_path_reloading(file_name)
  end
end

#require_without_load_path_reloadingObject

:nodoc:



7
# File 'lib/action_controller/test_process.rb', line 7

alias_method :require_without_load_path_reloading, :require

#subclasses_of(superclass) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/action_controller/support/core_ext/object_and_class.rb', line 6

def subclasses_of(superclass)
  subclasses = []
  ObjectSpace.each_object(Class) do |k|
    next if !k.ancestors.include?(superclass) || superclass == k || k.to_s.include?("::") || subclasses.include?(k.to_s)
    subclasses << k.to_s
  end
  subclasses
end