Last active
December 20, 2015 15:29
-
-
Save stestagg/6154353 to your computer and use it in GitHub Desktop.
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 foo | |
puts "A" | |
end | |
def self.bar | |
puts "B" | |
end | |
end | |
class B < A | |
end | |
# The 'false' below should only show methods 'directly on' the receiver: | |
# From the docs: If the all parameter is set to false, only those methods in the receiver will be listed. | |
p B.new.public_methods false # <- [] | |
p B.public_methods false # <- ["bar", "superclass", "allocate", "new"] | |
# Here 'bar' is defined on A, but included in the public_methods for B | |
# Calling public_methods(false) on the class includes methods on the superclass, but not on 'Object' which seems inconsistent. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment