Module: ActiveSupport::Dependencies::ModuleConstMissing

Defined in:
activesupport/lib/active_support/dependencies.rb

Overview

Module includes this module.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.append_features(base) ⇒ Object



160
161
162
163
164
165
166
167
168
# File 'activesupport/lib/active_support/dependencies.rb', line 160

def self.append_features(base)
  base.class_eval do
    # Emulate #exclude via an ivar
    return if defined?(@_const_missing) && @_const_missing
    @_const_missing = instance_method(:const_missing)
    remove_method(:const_missing)
  end
  super
end

.exclude_from(base) ⇒ Object



170
171
172
173
174
175
# File 'activesupport/lib/active_support/dependencies.rb', line 170

def self.exclude_from(base)
  base.class_eval do
    define_method :const_missing, @_const_missing
    @_const_missing = nil
  end
end

Instance Method Details

#const_missing(const_name) ⇒ Object



177
178
179
180
181
182
183
184
# File 'activesupport/lib/active_support/dependencies.rb', line 177

def const_missing(const_name)
  # The interpreter does not pass nesting information, and in the
  # case of anonymous modules we cannot even make the trade-off of
  # assuming their name reflects the nesting. Resort to Object as
  # the only meaningful guess we can make.
  from_mod = anonymous? ? ::Object : self
  Dependencies.load_missing_constant(from_mod, const_name)
end

#unloadable(const_desc = self) ⇒ Object



186
187
188
# File 'activesupport/lib/active_support/dependencies.rb', line 186

def unloadable(const_desc = self)
  super(const_desc)
end