Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kalleth
Created July 1, 2014 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalleth/a6142702dc2a8834320c to your computer and use it in GitHub Desktop.
Save kalleth/a6142702dc2a8834320c to your computer and use it in GitHub Desktop.
delegation_chain for SimpleDelegator objects to allow easy inspection of their delegation chain
class SimpleDelegator
def delegation_chain
[self].tap do |output|
object = self
while object.respond_to?("__getobj__")
object = object.__getobj__
output << object
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment