Last active
August 29, 2015 14:02
-
-
Save nagachika/07c08782f3fbe0d7b14f to your computer and use it in GitHub Desktop.
ActiveSupport::Dependencies and const_get(const, false)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def self.foo | |
puts "::A#foo" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_support/dependencies" | |
ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__) | |
class B | |
end | |
B.const_get(:A, false).foo rescue p $! # => ::A#foo | |
A.foo rescue p $! # => ::A#foo | |
B.const_get(:A, false).foo rescue p $! # => #<NameError: uninitialized constant B::A> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
#gem "activesupport", "~> 3.2.18" | |
gem "activesupport", "~> 4.1.1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment