Skip to content

Instantly share code, notes, and snippets.

@stestagg
Last active December 20, 2015 15:29
Show Gist options
  • Save stestagg/6154353 to your computer and use it in GitHub Desktop.
Save stestagg/6154353 to your computer and use it in GitHub Desktop.
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