Module: ActiveSupport::Dependencies
- Defined in:
- lib/invisible_controller/active_support_override.rb
Instance Method Summary collapse
- #before_raise_uninitialized_constant(qualified_name) ⇒ Object
-
#load_missing_constant(from_mod, const_name) ⇒ Object
RAILS code copied (RAILS Comments removed).
Instance Method Details
#before_raise_uninitialized_constant(qualified_name) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/invisible_controller/active_support_override.rb', line 47 def before_raise_uninitialized_constant(qualified_name) if !!(qualified_name =~ /Controller$/) return Object.const_set(qualified_name, InvisibleController::Base) end return false end |
#load_missing_constant(from_mod, const_name) ⇒ Object
RAILS code copied (RAILS Comments removed)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/invisible_controller/active_support_override.rb', line 8 def load_missing_constant(from_mod, const_name) log_call from_mod, const_name unless qualified_const_defined?(from_mod.name) && Inflector.constantize(from_mod.name).equal?(from_mod) raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!" end qualified_name = qualified_name_for from_mod, const_name path_suffix = qualified_name.underscore file_path = search_for_file(path_suffix) if file_path = File.(file_path) .sub!(/\.rb\z/, '') if loading.include?() raise "Circular dependency detected while autoloading constant #{qualified_name}" else require_or_load(, qualified_name) raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" unless from_mod.const_defined?(const_name, false) return from_mod.const_get(const_name) end elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix) return mod elsif (parent = from_mod.parent) && parent != from_mod && ! from_mod.parents.any? { |p| p.const_defined?(const_name, false) } begin return parent.const_missing(const_name) rescue NameError => e raise unless e.missing_name? qualified_name_for(parent, const_name) end end activated_name = before_raise_uninitialized_constant(qualified_name) return activated_name if activated_name.present? # Continue Rails code name_error = NameError.new("uninitialized constant #{qualified_name}", const_name) name_error.set_backtrace(caller.reject {|l| l.starts_with? __FILE__ }) raise name_error end |