Created
May 20, 2015 17:02
-
-
Save sshao/e8c975ae4a45b2fdf512 to your computer and use it in GitHub Desktop.
constant scoping
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 Ancestor; end | |
class Ancestor::DescOne | |
def self.desc_one_defined? | |
!!defined?(DescOne) | |
end | |
end | |
# Spork defines Spork::TestFramework::RSpec as: | |
# Spork::TestFramework::RSpec < Spork::TestFramework | |
class Ancestor::DescTwo < Ancestor | |
def self.desc_two_defined? | |
!!defined?(DescTwo) | |
end | |
end | |
puts "DescOne defined?: #{Ancestor::DescOne.desc_one_defined?}" # returns false | |
puts "DescTwo defined?: #{Ancestor::DescTwo.desc_two_defined?}" # returns true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment