ManageIQ / more_core_extensions

MoreCoreExtensions are a set of core extensions beyond those provided by ActiveSupport.
MIT License
5 stars 23 forks source link

Add Class#hierarchy and Class#lineage #61

Closed Fryguy closed 6 years ago

Fryguy commented 6 years ago

@bdunne Please review. See specs for examples.

I frequently need this in order to understand a given OO class hierarchy or lineage, so this is probably mostly for diagnostic usage, but useful nonetheless.

require 'socket'

IO.hierarchy
# => {BasicSocket=>
#      {Socket=>{},
#       IPSocket=>{TCPSocket=>{TCPServer=>{}}, UDPSocket=>{}},
#       UNIXSocket=>{UNIXServer=>{}}},
#     File=>{}}

TCPServer.lineage
# => [TCPSocket, IPSocket, BasicSocket, IO, Object, BasicObject]
miq-bot commented 6 years ago

Checked commit https://github.com/Fryguy/more_core_extensions/commit/8f5358fea87df1e8ec9a056057255945347823aa with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 4 files checked, 0 offenses detected Everything looks fine. :cake: